annotate mac/dw.m @ 1802:aedf5903db0a

Add DW_FCF_TEXTURED window style; relevant only for Mac port. Remove NSTexturedBackgroundWindowMask from style in dw_window_new. Add Copyright notice to winmain.c.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 27 Sep 2012 05:09:10 +0000
parents 9304241b7b33
children 2bcdc3cfffa7
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 *
1559
bc3a11fe9a46 Don't use _dw_pool_drain() in dw_exit() on Mac... that drains and recreates the pool.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1558
diff changeset
5 * (C) 2011-2012 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 *
1774
4cc999e757a3 Check for pointerArrayWithWeakObjects before weakObjectsPointerArray on Mac
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1773
diff changeset
8 * Requires 10.5 or later.
942
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>
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
20 #include <math.h>
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21
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
22 /* Create a define to let us know to include Snow Leopard specific features */
1740
2d44ca344863 Test fix for warnings generated in Xcode 4.3... hopefully this still allows 10.5 builds to work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1719
diff changeset
23 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED))
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
24 #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
25 #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
26
691
578bbfd8c904 Added 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 /* 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
28 #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
29 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
30 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
31 _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
32 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
33 [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
34 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
35 _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
36 #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
37 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
38 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
39 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
40 _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
41 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
42 _locked_by_me = FALSE; } }
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
43
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
44 /* Macros to handle local auto-release pools */
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
45 #define DW_LOCAL_POOL_IN NSAutoreleasePool *localpool = nil; \
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
46 if(DWThread != (DWTID)-1 && pthread_self() != DWThread) \
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
47 localpool = [[NSAutoreleasePool alloc] init];
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
48 #define DW_LOCAL_POOL_OUT if(localpool) [localpool drain];
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
49
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
50 unsigned long _colors[] =
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
51 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
52 0x00000000, /* 0 black */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
53 0x000000bb, /* 1 red */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
54 0x0000bb00, /* 2 green */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
55 0x0000aaaa, /* 3 yellow */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
56 0x00cc0000, /* 4 blue */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
57 0x00bb00bb, /* 5 magenta */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
58 0x00bbbb00, /* 6 cyan */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
59 0x00bbbbbb, /* 7 white */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
60 0x00777777, /* 8 grey */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
61 0x000000ff, /* 9 bright red */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
62 0x0000ff00, /* 10 bright green */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
63 0x0000eeee, /* 11 bright yellow */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
64 0x00ff0000, /* 12 bright blue */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
65 0x00ff00ff, /* 13 bright magenta */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
66 0x00eeee00, /* 14 bright cyan */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
67 0x00ffffff, /* 15 bright white */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
68 0xff000000 /* 16 default color */
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
69 };
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
70
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
71 /*
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
72 * 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
73 */
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
74 #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
75 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
76 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
77 ".png",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
78 ".ico",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
79 ".icns",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
80 ".gif",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
81 ".jpg",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
82 ".jpeg",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
83 ".tiff",
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
84 ".bmp"
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
85 };
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
86
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
87 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
88 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
89 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
90 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
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 /* 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
93 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
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 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
96 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
97 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
98 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
99 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
100 break;
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 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
103 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
104 {
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
105 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
106 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
107 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
108 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
109
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
110 unsigned long _get_color(unsigned long thiscolor)
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
111 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
112 if(thiscolor & DW_RGB_COLOR)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
113 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
114 return thiscolor & ~DW_RGB_COLOR;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
115 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
116 else if(thiscolor < 17)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
117 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
118 return _colors[thiscolor];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
119 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
120 return 0;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
121 }
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
122
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 /* 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
124 #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
125 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
126 #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
127 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
128 pthread_key_t _dw_bg_color_key;
1770
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
129 int DWOSMajor, DWOSMinor, DWOSBuild;
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
130 static char _dw_bundle_path[PATH_MAX+1] = { 0 };
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 /* 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
133 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
134 {
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
135 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
136
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
137 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
138 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
139 }
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
140
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
141 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
142 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
143 struct _sighandler *next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
144 ULONG message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
145 HWND window;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
146 int id;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
147 void *signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
148 void *data;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
149
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
150 } SignalHandler;
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
151
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 *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
153
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
154 /* Some internal prototypes */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 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
156 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
157 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
158 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
159
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
160 /* Internal function to queue a window redraw */
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
161 void _dw_redraw(id window, int skip)
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
162 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
163 static id lastwindow = nil;
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
164 id redraw = lastwindow;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
165
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
166 if(skip && window == nil)
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
167 return;
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
168
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
169 lastwindow = window;
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
170 if(redraw != lastwindow && redraw != nil)
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
171 {
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
172 dw_window_redraw(redraw);
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
173 }
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
174 }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
175
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
176 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
177 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
178 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
179
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
180 /* Find any callbacks for this function */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
181 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
182 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
183 if(tmp->message == messageid && window == tmp->window)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
184 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
185 return tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
186 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
187 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
188 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
189 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
190 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
191
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
192 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
193 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
194 ULONG message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
195 char name[30];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
196
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
197 } SignalList;
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
198
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
199 /* 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
200 #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
201
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
202 SignalList SignalTranslate[SIGNALMAX] = {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
203 { 1, DW_SIGNAL_CONFIGURE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
204 { 2, DW_SIGNAL_KEY_PRESS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
205 { 3, DW_SIGNAL_BUTTON_PRESS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
206 { 4, DW_SIGNAL_BUTTON_RELEASE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
207 { 5, DW_SIGNAL_MOTION_NOTIFY },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
208 { 6, DW_SIGNAL_DELETE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
209 { 7, DW_SIGNAL_EXPOSE },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
210 { 8, DW_SIGNAL_CLICKED },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
211 { 9, DW_SIGNAL_ITEM_ENTER },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
212 { 10, DW_SIGNAL_ITEM_CONTEXT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
213 { 11, DW_SIGNAL_LIST_SELECT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
214 { 12, DW_SIGNAL_ITEM_SELECT },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
215 { 13, DW_SIGNAL_SET_FOCUS },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
216 { 14, DW_SIGNAL_VALUE_CHANGED },
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
217 { 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
218 { 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
219 { 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
220 };
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
221
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
222 int _event_handler1(id object, NSEvent *event, int message)
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
223 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
224 SignalHandler *handler = _get_handler(object, message);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
225 /* 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
226
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
227 if(handler)
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 switch(message)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
230 {
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
231 /* Timer event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
232 case 0:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
233 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
234 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
235
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
236 if(!timerfunc(handler->data))
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
237 dw_timer_disconnect(handler->id);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
238 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
239 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
240 /* Configure/Resize event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
241 case 1:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
242 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
243 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
244 NSSize size;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
245
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
246 if([object isKindOfClass:[NSWindow class]])
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
247 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
248 NSWindow *window = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
249 size = [[window contentView] frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
250 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
251 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
252 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
253 NSView *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
254 size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
255 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
256
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
257 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
258 {
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
259 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
260 }
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
261 return 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
262 }
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
263 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
264 {
1748
e4fcd1e81f0d Added optional utf8 parameter to keypress callback on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
265 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction;
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
266 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
267 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
268 unichar vk = [nchar characterAtIndex:0];
1748
e4fcd1e81f0d Added optional utf8 parameter to keypress callback on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
269 char *utf8 = NULL, ch = '\0';
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
270
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
271 /* 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
272 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
273 {
1748
e4fcd1e81f0d Added optional utf8 parameter to keypress callback on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
274 char *tmp = (char *)[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
275 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
276 {
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
277 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
278 }
1748
e4fcd1e81f0d Added optional utf8 parameter to keypress callback on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
279 utf8 = tmp;
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
280 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
281
1748
e4fcd1e81f0d Added optional utf8 parameter to keypress callback on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
282 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8);
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
283 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
284 /* Button press and release event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
285 case 3:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
286 case 4:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
287 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
288 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
289 NSPoint p = [NSEvent mouseLocation];
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
290 int button = 1;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
291
1222
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
292 if([event isMemberOfClass:[NSEvent class]])
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
293 {
1222
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
294 id view = [[[event window] contentView] superview];
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
295 NSEventType type = [event type];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
296
1222
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
297 p = [view convertPoint:[event locationInWindow] toView:object];
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
298
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
299 if(type == NSRightMouseDown || type == NSRightMouseUp)
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
300 {
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
301 button = 2;
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
302 }
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
303 else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
304 {
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
305 button = 3;
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
306 }
1647
b2c26ed9031c On Mac set button to 2 (right) when Control key is pressed and left clicking
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1644
diff changeset
307 else if([event modifierFlags] & NSControlKeyMask)
b2c26ed9031c On Mac set button to 2 (right) when Control key is pressed and left clicking
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1644
diff changeset
308 {
b2c26ed9031c On Mac set button to 2 (right) when Control key is pressed and left clicking
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1644
diff changeset
309 button = 2;
b2c26ed9031c On Mac set button to 2 (right) when Control key is pressed and left clicking
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1644
diff changeset
310 }
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
311 }
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
312
954
cfb12bf3bb06 Fixes for some more coordinate system issues on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 953
diff changeset
313 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
314 }
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
315 /* 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
316 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
317 {
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
318 int (* API motionfunc)(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
319 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
320 NSPoint p = [view convertPoint:[event locationInWindow] toView:object];
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
321 SEL spmb = NSSelectorFromString(@"pressedMouseButtons");
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
322 IMP ipmb = [[NSEvent class] respondsToSelector:spmb] ? [[NSEvent class] methodForSelector:spmb] : 0;
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
323 int buttonmask = ipmb ? (int)ipmb([NSEvent class], spmb) : (1 << [event buttonNumber]);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
324
954
cfb12bf3bb06 Fixes for some more coordinate system issues on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 953
diff changeset
325 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
326 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
327 /* Window close event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
328 case 6:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
329 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
330 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
331 return closefunc(object, handler->data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
332 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
333 /* Window expose/draw event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
334 case 7:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
335 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
336 DWExpose exp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
337 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
338 NSRect rect = [object frame];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
339
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
340 exp.x = rect.origin.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
341 exp.y = rect.origin.y;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
342 exp.width = rect.size.width;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
343 exp.height = rect.size.height;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
344 int result = exposefunc(object, &exp, handler->data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
345 [[object window] flushWindow];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
346 return result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
347 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
348 /* Clicked event for buttons and menu items */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
349 case 8:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
350 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
351 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
352
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
353 return clickfunc(object, handler->data);
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 /* 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
356 case 9:
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
357 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
358 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
359
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
360 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
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 /* Container context menu event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
363 case 10:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
364 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
365 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
366 char *text = (char *)event;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
367 void *user = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
368 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
369
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
370 /* 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
371 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
372 {
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
373 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
374 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
375 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
376 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
377 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
378 {
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
379 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
380 }
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
381 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
382
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
383 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
384
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
385 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
386 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
387 /* 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
388 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
389 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
390 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
391 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
392 int selected = DW_POINTER_TO_INT(event);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
393
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
394 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
395 }
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
396 /* Tree class selection event */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
397 case 12:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
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 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
400 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
401 void *user = NULL;
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
402 id item = nil;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
403
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
404 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
405 {
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
406 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
407 NSString *nstr = [item objectAtIndex:1];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
408
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
409 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
410 {
01107d8e033e Fixed the scrollbar maximum range to be correct. Also added some MLE code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 711
diff changeset
411 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
412 }
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
413 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
414 {
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
415 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
416 }
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
417
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
418 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
419 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
420 {
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
421 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
422 }
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
423 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
424 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
425 {
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
426 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
427 }
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
428 return result;
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
429 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
430
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
431 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
432 }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
433 /* 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
434 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
435 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
436 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
437
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
438 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
439 }
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
440 /* 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
441 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
442 {
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
443 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
444 int pageid = DW_POINTER_TO_INT(event);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
445
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
446 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
447 }
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
448 case 16:
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
449 {
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
450 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
451
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
452 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data);
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
453 }
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
454 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
455 {
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
456 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
457 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
458
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
459 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
460 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
461 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
462 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
463 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
464 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
466 /* Sub function to handle redraws */
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
467 int _event_handler(id object, NSEvent *event, int message)
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
468 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
469 int ret = _event_handler1(object, event, message);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
470 if(ret != -1)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
471 _dw_redraw(nil, FALSE);
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
472 return ret;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
473 }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
474
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
475 /* Subclass for the Timer type */
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
476 @interface DWTimerHandler : NSObject { }
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
477 -(void)runTimer:(id)sender;
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
478 @end
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
479
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
480 @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
481 -(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
482 @end
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
483
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
484 NSApplication *DWApp;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
485 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
486 NSFont *DWDefaultFont;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
487 DWTimerHandler *DWHandler;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
488 #if !defined(GARBAGE_COLLECT)
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
489 NSAutoreleasePool *pool;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
490 #endif
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
491 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
492 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
493 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
494 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
495 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
496 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
497
1558
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
498 /* Send fake event to make sure the loop isn't stuck */
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
499 void _dw_wakeup_app()
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
500 {
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
501 [DWApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
502 location:NSMakePoint(0, 0)
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
503 modifierFlags:0
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
504 timestamp:0
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
505 windowNumber:0
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
506 context:NULL
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
507 subtype:0
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
508 data1:0
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
509 data2:0]
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
510 atStart:NO];
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
511 }
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
512
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
513 /* 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
514 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
515 {
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
516 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
517 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
518 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
519 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
520 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
521 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
522 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
523 int ysrc;
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
524 int srcwidth;
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
525 int srcheight;
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 } DWBitBlt;
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
527
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
528 /* 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
529 @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
530 -(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
531 -(void)synchronizeThread:(id)param;
1378
a54720b10821 Fix menu items getting stuck highlighted on Mac if the action triggered a window focus change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1376
diff changeset
532 -(void)menuHandler:(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
533 -(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
534 -(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
535 @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
536
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
537 @interface DWMenuItem : NSMenuItem
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
538 {
1517
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
539 int check;
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
540 }
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
541 -(void)setCheck:(int)input;
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
542 -(int)check;
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
543 -(void)dealloc;
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
544 @end
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
545
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
546 @implementation DWObject
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
547 -(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
548 -(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
549 {
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
550 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
551 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
552 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
553 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
554 }
1378
a54720b10821 Fix menu items getting stuck highlighted on Mac if the action triggered a window focus change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1376
diff changeset
555 -(void)menuHandler:(id)param
a54720b10821 Fix menu items getting stuck highlighted on Mac if the action triggered a window focus change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1376
diff changeset
556 {
1517
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
557 DWMenuItem *item = param;
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
558 if([item check])
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
559 {
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
560 if([item state] == NSOnState)
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
561 [item setState:NSOffState];
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
562 else
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
563 [item setState:NSOnState];
1517
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
564 }
1378
a54720b10821 Fix menu items getting stuck highlighted on Mac if the action triggered a window focus change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1376
diff changeset
565 _event_handler(param, nil, 8);
a54720b10821 Fix menu items getting stuck highlighted on Mac if the action triggered a window focus change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1376
diff changeset
566 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
567 -(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
568 {
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
569 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
570 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
571 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
572 id bltsrc = bltinfo->src;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
573
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
574 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
575 {
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
576 [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
577 [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
578 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
579 [[[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil] autorelease];
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
580 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
581 else
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
582 {
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
583 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
584 {
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
585 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
586 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
587 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
588 _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
589 }
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
590 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
591 {
910
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
592 NSBitmapImageRep *rep = bltsrc;
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
593 NSImage *image = [NSImage alloc];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
594 SEL siwc = NSSelectorFromString(@"initWithCGImage");
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
595
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
596 if([image respondsToSelector:siwc])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
597 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
598 IMP iiwc = [image methodForSelector:siwc];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
599 image = iiwc(image, siwc, [rep CGImage], NSZeroSize);
910
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
600 }
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
601 else
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
602 {
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
603 image = [image initWithSize:[rep size]];
910
329f2ca62f1b Switched to using a different potentially slower NSImage conversion to support Leopard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 909
diff changeset
604 [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
605 }
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
606 if(bltinfo->srcwidth != -1)
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
607 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
608 [image drawInRect:NSMakeRect(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height)
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
609 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->srcwidth, bltinfo->srcheight)
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
610 operation:NSCompositeSourceOver fraction:1.0];
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
611 }
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
612 else
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
613 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
614 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest)
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
615 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
616 operation:NSCompositeSourceOver fraction:1.0];
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
617 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
618 [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
619 [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
620 }
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
621 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
622 {
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
623 [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
624 }
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
625 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
626 {
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
627 [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
628 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
629 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
630 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
631 -(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
632 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
633 if(_DWLastDrawable)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
634 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
635 id object = _DWLastDrawable;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
636 NSWindow *window = [object window];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
637 [window flushWindow];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
638 }
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
639 }
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
640 -(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
641 {
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
642 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
643 void **params = (void **)[v pointerValue];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
644 void (* windowfunc)(void *);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
645
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
646 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
647 {
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
648 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
649 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
650 {
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
651 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
652 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
653 }
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
654 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
655 @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
656
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
657 DWObject *DWObj;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
658
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
659 /* 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
660 * 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
661 * basically everything. Was hoping to add methods
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
662 * 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
663 * 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
664 * going to work. -Brian
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 /* Subclass for a box type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
668 @interface DWBox : NSView
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
670 Box *box;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
671 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
672 NSColor *bgcolor;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673 }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
674 -(id)init;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
675 -(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
676 -(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
677 -(id)contentView;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679 -(void)setUserdata:(void *)input;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
680 -(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
681 -(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
682 -(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
683 -(void)mouseUp:(NSEvent *)theEvent;
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
684 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
685 -(void)rightMouseUp:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
686 -(void)otherMouseDown:(NSEvent *)theEvent;
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
687 -(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
688 -(void)keyDown:(NSEvent *)theEvent;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
689 -(void)setColor:(unsigned long)input;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
692 @implementation DWBox
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
693 -(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
694 {
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
695 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
696
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
697 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
698 {
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
699 box = calloc(1, sizeof(Box));
1453
4b516ef23b62 Boxes need to default to vertical on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
700 box->type = DW_VERT;
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
701 box->vsize = box->hsize = SIZEEXPAND;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
702 box->width = box->height = 1;
666
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
703 }
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
704 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
705 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
706 -(void)dealloc
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
707 {
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
708 UserData *root = userdata;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
709 if(box->items)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
710 free(box->items);
666
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
711 free(box);
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
712 _remove_userdata(&root, NULL, TRUE);
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
713 dw_signal_disconnect_by_window(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
714 [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
715 }
e426de6e6c7c Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 665
diff changeset
716 -(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
717 -(id)contentView { return self; }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 -(void)setUserdata:(void *)input { userdata = input; }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
720 -(void)drawRect:(NSRect)rect
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
722 if(bgcolor)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
723 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
724 [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
725 NSRectFill([self bounds]);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
726 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 }
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
728 -(BOOL)isFlipped { return YES; }
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
729 -(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
730 -(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
731 -(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
732 -(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
733 -(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
734 -(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
735 -(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
736 -(void)setColor:(unsigned long)input
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
737 {
755
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
738 id orig = bgcolor;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
739
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
740 if(input == _colors[DW_CLR_DEFAULT])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
741 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
742 bgcolor = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
743 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
744 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
745 {
755
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
746 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
747 [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
748 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
749 [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
750 }
f574028932cc Fix for crash when changing background colors, needed retain and release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 754
diff changeset
751 [orig release];
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
752 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754
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
755 /* 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
756 @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
757 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
758 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
759 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
760 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
761 }
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
762 -(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
763 -(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
764 -(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
765 @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
766
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
767 @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
768 -(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
769 -(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
770 -(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
771 -(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
772 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
773 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
774
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
775 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
776 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
777 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
778 [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
779 }
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
780 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
781 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
782
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
783 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
784 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
785 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
786 }
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
787 -(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
788 @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
789
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
790 @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
791 {
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
792 int redraw;
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
793 int shown;
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
794 }
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
795 -(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
796 -(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
797 -(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
798 -(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
799 -(void)setRedraw:(int)val;
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
800 -(int)shown;
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
801 -(void)setShown:(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
802 @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
803
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
804 @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
805 -(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
806 {
1133
25bea6526ca1 Similar Mac fix to what I just commited on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1130
diff changeset
807 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
808 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
809 {
ab73d0269a5b Ensure default keypress event is not processed if handler returns 1
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1128
diff changeset
810 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
811 }
1133
25bea6526ca1 Similar Mac fix to what I just commited on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1130
diff changeset
812 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
813 [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
814 }
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
815 -(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
816 -(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
817 -(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
818 -(void)setRedraw:(int)val { redraw = val; }
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
819 -(int)shown { return shown; }
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
820 -(void)setShown:(int)val { shown = 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
821 @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
822
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
823 /* 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
824 @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
825 {
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
826 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
827 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
828 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
829 }
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
830 -(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
831 -(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
832 -(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
833 -(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
834 -(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
835 -(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
836 -(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
837 -(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
838 -(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
839 -(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
840 -(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
841 -(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
842 -(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
843 -(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
844 -(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
845 @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
846
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
847 @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
848 -(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
849 -(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
850 -(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
851 -(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
852 -(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
853 -(NSSize)size { return size; }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
854 -(void)mouseDown:(NSEvent *)theEvent
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
855 {
1652
202b1affc706 Fix taskbar/menubar event breakage from the recent Mac control key changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1650
diff changeset
856 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & NSControlKeyMask))
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
857 _event_handler(self, theEvent, 3);
1648
7a9b1189934a Another fix for Contol clicking on Mac... getting double events
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1647
diff changeset
858 }
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
859 -(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
860 -(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
861 -(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
862 -(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
863 -(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
864 -(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
865 -(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
866 -(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
867 -(BOOL)isFlipped { return YES; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
868 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; dw_signal_disconnect_by_window(self); [super dealloc]; }
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
869 -(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
870 @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
871
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 /* Subclass for a top-level window */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
873 @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
874 #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
875 <NSWindowDelegate>
d44bb4c4902d Fixed an error on the close event handler on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 853
diff changeset
876 #endif
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
877 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
878 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
879 NSSize oldsize;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
880 }
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
881 -(BOOL)windowShouldClose:(id)sender;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
882 -(void)setMenu:(NSMenu *)input;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
883 -(void)windowDidBecomeMain:(id)sender;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
884 -(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
885 -(void)mouseDragged:(NSEvent *)theEvent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888 @implementation DWView
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
889 -(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
890 {
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
891 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
892 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
893 return YES;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895 - (void)viewDidMoveToWindow
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
897 [[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
898 [[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
899 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 - (void)dealloc
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 {
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
902 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
903 {
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
904 [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
905 }
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
906 [[NSNotificationCenter defaultCenter] removeObserver:self];
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
907 dw_signal_disconnect_by_window(self);
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
908 [super dealloc];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 - (void)windowResized:(NSNotification *)notification;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
912 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
913
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
914 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
915 {
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
916 _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
917 _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
918 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
919 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
920 _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
921 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922 }
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
923 -(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
924 {
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
925 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
926
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
927 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
928 {
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
929 _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
930 _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
931 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
932
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
933 }
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
934 -(void)windowDidBecomeMain:(id)sender
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
935 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
936 if(windowmenu)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
937 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
938 [DWApp setMainMenu:windowmenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
939 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
940 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
941 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
942 [DWApp setMainMenu:DWMainMenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
943 }
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
944 _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
945 }
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
946 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
947 -(void)menuHandler:(id)sender
1593
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
948 {
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
949 id menu = [sender menu];
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
950
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
951 /* Find the highest menu for this item */
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
952 while([menu supermenu])
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
953 {
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
954 menu = [menu supermenu];
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
955 }
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
956
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
957 /* Only perform the delay if this item is a child of the main menu */
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
958 if([DWApp mainMenu] == menu)
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
959 [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0];
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
960 else
19af25f71e1f Yet another fix attempt for mene item issues on Mac 10.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1590
diff changeset
961 [DWObj menuHandler:sender];
1558
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
962 _dw_wakeup_app();
1522
c98b2ce2d5b2 Fix menuHandler not being called until an event on Mac 10.5. This reinstitutes the menu display bug on Leopard but that is only a cosmetic issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1517
diff changeset
963 }
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
964 -(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
965 -(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
966 {
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
967 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
968
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
969 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
970 {
abb9203adc05 Use NSCompositeSourceOver for bitblting that respects transparency of the source
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 951
diff changeset
971 _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
972 }
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
973 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 /* Subclass for a button type */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 @interface DWButton : NSButton
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
978 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
979 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
980 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
981 DWBox *parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
983 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 -(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
985 -(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
986 -(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
987 -(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
988 -(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
989 -(DWBox *)parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 @implementation DWButton
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 -(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
995 -(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
996 {
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
997 _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
998 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
999 {
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
1000 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
1001 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
1002 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
1003
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
1004 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
1005 {
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
1006 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
1007 {
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
1008 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
1009
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
1010 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
1011 {
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
1012 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
1013
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
1014 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
1015 {
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
1016 [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
1017 }
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
1018 }
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
1019 }
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
1020 }
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
1021 }
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
1022 }
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
1023 -(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
1024 -(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
1025 -(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
1026 -(DWBox *)parent { return parent; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1027 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 /* Subclass for a progress type */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 @interface DWPercent : NSProgressIndicator
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1033 void *userdata;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 -(void *)userdata;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 -(void)setUserdata:(void *)input;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 @implementation DWPercent
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040 -(void *)userdata { return userdata; }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 -(void)setUserdata:(void *)input { userdata = input; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1042 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1043 @end
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1044
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1045 /* Subclass for a menu item type */
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1046 @implementation DWMenuItem
1517
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
1047 -(void)setCheck:(int)input { check = input; }
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
1048 -(int)check { return check; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1049 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 @end
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1052 /* 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
1053 @interface DWScrollBox : NSScrollView
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1054 {
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1055 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
1056 id box;
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1057 }
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1058 -(void *)userdata;
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1059 -(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
1060 -(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
1061 -(id)box;
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1062 @end
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1063
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1064 @implementation DWScrollBox
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1065 -(void *)userdata { return userdata; }
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1066 -(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
1067 -(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
1068 -(id)box { return box; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1069 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1070 @end
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
1071
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1072 /* 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
1073 @interface DWTextFieldCell : NSTextFieldCell
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1074 {
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1075 BOOL vcenter;
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1076 }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1077 -(NSRect)drawingRectForBounds:(NSRect)theRect;
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1078 -(void)setVCenter:(BOOL)input;
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1079 @end
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1080
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1081 @implementation DWTextFieldCell
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1082 -(NSRect)drawingRectForBounds:(NSRect)theRect
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1083 {
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1084 /* Get the parent's idea of where we should draw */
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1085 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
1086
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1087 /* If we are being vertically centered */
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1088 if(vcenter)
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1089 {
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1090 /* Get our ideal size for current text */
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1091 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
1092
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1093 /* Center that in the proposed rect */
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1094 float heightDelta = newRect.size.height - textSize.height;
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1095 if (heightDelta > 0)
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1096 {
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1097 newRect.size.height -= heightDelta;
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1098 newRect.origin.y += (heightDelta / 2);
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1099 }
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1100 }
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1101
860
93ac372941c4 Formatting cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 859
diff changeset
1102 return newRect;
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1103 }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1104 -(void)setVCenter:(BOOL)input { vcenter = input; }
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1105 @end
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
1106
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1107 @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
1108 {
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1109 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
1110 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1111 - (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
1112 - (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
1113 @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
1114
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1115 /* 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
1116 * 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
1117 */
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1118 @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
1119 -(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
1120 {
1063
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
1121 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
1122 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
1123 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
1124 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1125 -(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
1126 -(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
1127 -(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
1128 -(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
1129 -(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
1130 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
1131 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
1132 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
1133 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
1134 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1135 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
1136 {
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1137 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
1138 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1139 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
1140 }
29d8ae25a78c Implemented dw_entryfield_set_limit() on the Mac using a custom formatter class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 886
diff changeset
1141 -(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
1142 @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
1143
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1144 /* Subclass for a entryfield type */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1145 @interface DWEntryField : NSTextField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1146 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1147 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
1148 id clickDefault;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1149 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1150 -(void *)userdata;
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1151 -(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
1152 -(void)setClickDefault:(id)input;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1153 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1154
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1155 @implementation DWEntryField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1156 -(void *)userdata { return userdata; }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1157 -(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
1158 -(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
1159 -(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
1160 {
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
1161 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
1162 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
1163 {
1236
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1164 if([clickDefault isKindOfClass:[NSButton class]])
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1165 [clickDefault buttonClicked:self];
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1166 else
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1167 [[self window] makeFirstResponder:clickDefault];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1168 } else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1169 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1170 [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
1171 }
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
1172 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1173 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1174 {
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1175 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask)
1235
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1176 {
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1177 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1178 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1179 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1180 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1181 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"v"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1182 return [NSApp sendAction:@selector(paste:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1183 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"a"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1184 return [NSApp sendAction:@selector(selectAll:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1185 }
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1186 return [super performKeyEquivalent:theEvent];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1187 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1188 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1189 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1190
1564
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1191 /* Subclass for a text and status text type */
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1192 @interface DWText : NSTextField
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1193 {
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1194 void *userdata;
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1195 id clickDefault;
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1196 }
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1197 -(void *)userdata;
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1198 -(void)setUserdata:(void *)input;
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1199 @end
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1200
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1201 @implementation DWText
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1202 -(void *)userdata { return userdata; }
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1203 -(void)setUserdata:(void *)input { userdata = input; }
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1204 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1205 @end
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1206
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
1207
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1208 /* Subclass for a entryfield password type */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1209 @interface DWEntryFieldPassword : NSSecureTextField
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1210 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1211 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
1212 id clickDefault;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1213 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1214 -(void *)userdata;
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1215 -(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
1216 -(void)setClickDefault:(id)input;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1217 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1218
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1219 @implementation DWEntryFieldPassword
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1220 -(void *)userdata { return userdata; }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1221 -(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
1222 -(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
1223 -(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
1224 {
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
1225 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
1226 {
1236
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1227 if([clickDefault isKindOfClass:[NSButton class]])
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1228 [clickDefault buttonClicked:self];
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1229 else
46de4dbe710d Fixed clickdefault not triggering event for buttons on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1235
diff changeset
1230 [[self window] makeFirstResponder:clickDefault];
1235
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1231 }
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1232 else
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1233 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
1234 [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
1235 }
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
1236 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1237 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1238 {
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1239 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask)
1235
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1240 {
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1241 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1242 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1243 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1244 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1245 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"v"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1246 return [NSApp sendAction:@selector(paste:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1247 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"a"])
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1248 return [NSApp sendAction:@selector(selectAll:) to:[[self window] firstResponder] from:self];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1249 }
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1250 return [super performKeyEquivalent:theEvent];
9327f684c9b8 Attempt at fixing Copy, Cut, Paste, Select All Mac key combos...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1234
diff changeset
1251 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1252 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1253 @end
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
1254
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1255 /* Subclass for a Notebook control type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1256 @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
1257 #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
1258 <NSTabViewDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1259 #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
1260 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1261 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1262 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
1263 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1264 -(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
1265 -(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
1266 -(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
1267 -(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
1268 -(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
1269 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1270
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1271 /* 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
1272 @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
1273 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1274 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1275 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
1276 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1277 -(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
1278 -(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
1279 -(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
1280 -(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
1281 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1282
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1283 @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
1284 -(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
1285 -(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
1286 -(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
1287 -(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
1288 -(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
1289 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1290 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
1291 DWNotebookPage *page = (DWNotebookPage *)notepage;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1292
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1293 if([object isMemberOfClass:[DWBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1294 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1295 DWBox *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1296 Box *box = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1297 NSSize size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1298 _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
1299 _handle_resize_events(box);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1300 }
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
1301 _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
1302 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1303 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1304 @end
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
1305
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1306 @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
1307 -(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
1308 -(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
1309 -(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
1310 -(void)setPageid:(int)input { pageid = input; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1311 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [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
1312 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1313
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1314 /* Subclass for a color chooser type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1315 @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
1316 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1317 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
1318 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
1319 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1320 -(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
1321 -(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
1322 -(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
1323 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1324
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1325 @implementation DWColorChoose
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1326 -(void)changeColor:(id)sender
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1327 {
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1328 if(!dialog)
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1329 [self close];
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1330 else
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1331 pickedcolor = [self color];
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1332 }
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1333 -(BOOL)windowShouldClose:(id)window
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1334 {
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1335 if(dialog)
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1336 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1337 DWDialog *d = dialog;
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1338 dialog = nil;
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1339 dw_dialog_dismiss(d, pickedcolor);
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1340 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1341 [self close];
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1342 return NO;
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
1343 }
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1344 -(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
1345 -(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
1346 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1347
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1348 /* 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
1349 @interface DWFontChoose : NSFontPanel
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1350 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1351 DWDialog *dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1352 NSFontManager *fontManager;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1353 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1354 -(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
1355 -(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
1356 -(DWDialog *)dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1357 @end
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1358
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1359 @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
1360 -(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
1361 {
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1362 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
1363 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
1364 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
1365 [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
1366 return NO;
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1367 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1368 -(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
1369 -(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
1370 -(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
1371 @end
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
1372
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1373 /* Subclass for a splitbar type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1374 @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
1375 #ifdef BUILDING_FOR_SNOW_LEOPARD
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1376 <NSSplitViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1377 #endif
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1378 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1379 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
1380 float percent;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1381 }
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1382 -(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
1383 -(void *)userdata;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1384 -(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
1385 -(float)percent;
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1386 -(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
1387 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1388
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1389 @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
1390 -(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
1391 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1392 NSArray *views = [self subviews];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1393 id object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1394
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1395 for(object in views)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1396 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1397 if([object isMemberOfClass:[DWBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1398 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1399 DWBox *view = object;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1400 Box *box = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1401 NSSize size = [view frame].size;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1402 _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
1403 _handle_resize_events(box);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1404 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1405 }
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1406 }
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
1407 -(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
1408 -(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
1409 -(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
1410 -(void)setPercent:(float)input { percent = input; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1411 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [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
1412 @end
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
1413
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1414 /* 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
1415 @interface DWSlider : NSSlider
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1416 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1417 void *userdata;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1418 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1419 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1420 -(void)setUserdata:(void *)input;
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
1421 -(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
1422 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1423
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1424 @implementation DWSlider
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1425 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1426 -(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
1427 -(void)sliderChanged:(id)sender { _event_handler(self, (void *)[self integerValue], 14); }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1428 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1429 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1430
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1431 /* 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
1432 @interface DWScrollbar : NSScroller
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1433 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1434 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
1435 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
1436 double visible;
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
1437 int vertical;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1438 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1439 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1440 -(void)setUserdata:(void *)input;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1441 -(float)range;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1442 -(float)visible;
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
1443 -(int)vertical;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
1444 -(void)setVertical:(int)value;
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
1445 -(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
1446 -(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
1447 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1448
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1449 @implementation DWScrollbar
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1450 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1451 -(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
1452 -(float)range { return range; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1453 -(float)visible { return visible; }
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
1454 -(int)vertical { return vertical; }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
1455 -(void)setVertical:(int)value { vertical = value; }
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
1456 -(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
1457 -(void)scrollerChanged:(id)sender
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1458 {
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
1459 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
1460 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
1461 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
1462
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1463 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
1464 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1465
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
1466 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
1467 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
1468 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1469 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
1470 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1471 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1472
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
1473 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
1474 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
1475 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1476 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
1477 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1478 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1479
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
1480 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
1481 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
1482 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
1483 {
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1484 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
1485 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1486 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1487
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
1488 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
1489 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
1490 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
1491 {
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
1492 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
1493 }
86d76fc09237 Added support for scrollbar line and page scrolling. Need to check the calculations...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 706
diff changeset
1494 break;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1495
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
1496 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
1497 ; /* 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
1498 }
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
1499 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
1500 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
1501 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
1502 {
923
0ac67b62b594 Fix int to double conversion issues causing scrollbar issues on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 922
diff changeset
1503 [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
1504 }
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
1505 _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
1506 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1507 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1508 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1509
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1510 /* Subclass for a MLE type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1511 @interface DWMLE : NSTextView
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1512 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1513 void *userdata;
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
1514 id scrollview;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1515 }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1516 -(void *)userdata;
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1517 -(void)setUserdata:(void *)input;
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
1518 -(id)scrollview;
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
1519 -(void)setScrollview:(id)input;
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1520 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1521
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1522 @implementation DWMLE
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1523 -(void *)userdata { return userdata; }
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1524 -(void)setUserdata:(void *)input { userdata = input; }
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
1525 -(id)scrollview { return scrollview; }
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
1526 -(void)setScrollview:(id)input { scrollview = input; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
1527 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
653
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1528 @end
36c6669422d2 Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 652
diff changeset
1529
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1530 /* Subclass NSTextFieldCell for displaying image and text */
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1531 @interface DWImageAndTextCell : NSTextFieldCell
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1532 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1533 @private
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1534 NSImage *image;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1535 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1536 -(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
1537 -(NSImage *)image;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1538 -(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
1539 -(NSSize)cellSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1540 @end
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1541
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1542 @implementation DWImageAndTextCell
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1543 -(void)dealloc
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1544 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1545 [image release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1546 image = nil;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1547 [super dealloc];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1548 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1549 -copyWithZone:(NSZone *)zone
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1550 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1551 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
1552 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
1553 return cell;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1554 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1555 -(void)setImage:(NSImage *)anImage
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1556 {
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1557 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
1558 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1559 [image release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1560 image = [anImage retain];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1561 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1562 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1563 -(NSImage *)image
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1564 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1565 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
1566 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1567 -(NSRect)imageFrameForCellFrame:(NSRect)cellFrame
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1568 {
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1569 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
1570 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1571 NSRect imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1572 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
1573 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
1574 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
1575 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
1576 return imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1577 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1578 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1579 return NSZeroRect;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1580 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1581 -(void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1582 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1583 NSRect textFrame, imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1584 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
1585 [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
1586 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1587 -(void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1588 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1589 NSRect textFrame, imageFrame;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1590 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
1591 [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
1592 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1593 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1594 {
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1595 if(image != nil)
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1596 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1597 NSSize imageSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1598 NSRect imageFrame;
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1599 SEL sdir = NSSelectorFromString(@"drawInRect:fromRect:operation:fraction:respectFlipped:hints:");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1600
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1601 imageSize = [image size];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1602 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1603 if ([self drawsBackground])
1210
5a016a5a7412 Slight change in design behavior for dw_container_set_row_bg()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1206
diff changeset
1604 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1605 [[self backgroundColor] set];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1606 NSRectFill(imageFrame);
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1607 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1608 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
1609 imageFrame.size = imageSize;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1610
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1611 /* New method for 10.6 and later */
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1612 if([image respondsToSelector:sdir])
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1613 {
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1614 IMP idir = [image methodForSelector:sdir];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1615
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1616 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1617
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1618 idir(image, sdir, imageFrame, NSZeroRect, NSCompositeSourceOver, 1.0, YES, nil);
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1619 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1620 else
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1621 {
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1622 /* Old method for 10.5 */
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1623 SEL sctp = NSSelectorFromString(@"compositeToPoint:operation:");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1624
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1625 if ([controlView isFlipped])
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1626 imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.height) / 2);
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1627 else
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1628 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1629
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1630 if([image respondsToSelector:sctp])
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1631 {
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1632 IMP ictp = [image methodForSelector:sctp];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1633
1779
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1634 ictp(image, sctp, imageFrame.origin, NSCompositeSourceOver);
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1635 }
f77b76c86d19 Readd support for 10.5... the drawInRect method I was using only supports 10.6 and higher...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1778
diff changeset
1636 }
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1637 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1638 [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
1639 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1640 -(NSSize)cellSize
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1641 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1642 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
1643 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
1644 return cellSize;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1645 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1646 @end
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1647
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
1648 /* Subclass for a Container/List type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1649 @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
1650 #ifdef BUILDING_FOR_SNOW_LEOPARD
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1651 <NSTableViewDataSource,NSTableViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1652 #endif
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1653 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1654 void *userdata;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1655 NSMutableArray *tvcols;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1656 NSMutableArray *data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1657 NSMutableArray *types;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1658 NSPointerArray *titles;
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1659 NSColor *fgcolor, *oddcolor, *evencolor;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1660 int lastAddPoint, lastQueryPoint;
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1661 id scrollview;
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1662 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
1663 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
1664 -(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
1665 -(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
1666 -(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
1667 -(void *)userdata;
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1668 -(void)setUserdata:(void *)input;
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
1669 -(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
1670 -(int)filesystem;
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1671 -(id)scrollview;
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
1672 -(void)setScrollview:(id)input;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1673 -(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
1674 -(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
1675 -(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
1676 -(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
1677 -(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
1678 -(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
1679 -(void)removeRow:(int)row;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1680 -(void)setRow:(int)row title:(void *)input;
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1681 -(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
1682 -(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
1683 -(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
1684 -(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
1685 -(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
1686 -(void)setLastQueryPoint:(int)input;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1687 -(void)clear;
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1688 -(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
1689 -(void)optimize;
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1690 -(NSSize)getsize;
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
1691 -(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
1692 -(void)doubleClicked:(id)sender;
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
1693 -(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
1694 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1695 -(void)selectionChanged:(id)sender;
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1696 -(NSMenu *)menuForEvent:(NSEvent *)event;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1697 @end
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1698
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
1699 @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
1700 -(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
1701 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1702 if(tvcols && data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1703 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1704 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
1705 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
1706 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
1707 {
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1708 return total / cols;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1709 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1710 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1711 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
1712 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
1713 -(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
1714 {
1134
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1715 if(tvcols && data)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1716 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1717 int z, col = -1;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1718 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
1719
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1720 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1721 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1722 if([tvcols objectAtIndex:z] == aCol)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1723 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1724 col = z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1725 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1726 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1727 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1728 if(col != -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1729 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1730 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
1731 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
1732 {
41a93f9896e3 Avoid an array out of bounds after container clear on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1133
diff changeset
1733 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
1734 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
1735 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1736 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1737 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1738 return nil;
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1739 }
708
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
1740 -(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
1741 -(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
1742 -(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
1743 -(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
1744 -(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
1745 -(id)scrollview { return scrollview; }
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
1746 -(void)setScrollview:(id)input { scrollview = input; }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1747 -(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
1748 -(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
1749 -(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
1750 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1751 NSColor *oldodd = oddcolor;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1752 NSColor *oldeven = evencolor;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1753 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
1754 unsigned long _even = _get_color(evencol);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1755
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1756 /* 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
1757 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
1758 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
1759 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1760 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
1761 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
1762 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
1763 else
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1764 evencolor = NULL;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1765 [oldodd release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1766 [oldeven release];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1767 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1768 -(int)insertRow:(NSArray *)input at:(int)index
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1769 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1770 if(data)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1771 {
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1772 unsigned long start = [tvcols count] * index;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1773 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
1774 if(index < lastAddPoint)
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1775 {
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1776 lastAddPoint++;
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1777 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1778 [data insertObjects:input atIndexes:set];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1779 [titles insertPointer:NULL atIndex:index];
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
1780 [set release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1781 return (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1782 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1783 return 0;
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1784 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1785 -(int)addRow:(NSArray *)input
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1786 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1787 if(data)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1788 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1789 lastAddPoint = (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1790 [data addObjectsFromArray:input];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1791 [titles addPointer:NULL];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1792 return (int)[titles count];
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1793 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1794 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
1795 }
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
1796 -(int)addRows:(int)number
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1797 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1798 if(tvcols)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1799 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1800 int count = (int)(number * [tvcols count]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1801 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1802
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1803 lastAddPoint = (int)[titles count];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1804
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1805 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1806 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1807 [data addObject:[NSNull null]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1808 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1809 for(z=0;z<number;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1810 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1811 [titles addPointer:NULL];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1812 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1813 return (int)[titles count];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1814 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1815 return 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1816 }
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
1817 -(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
1818 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1819 DWImageAndTextCell *bcell = cell;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1820
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1821 /* 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
1822 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
1823 {
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
1824 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
1825 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
1826 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
1827 [bcell setImage:img];
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1828 }
1215
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1829 if([cell isKindOfClass:[NSTextFieldCell class]])
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1830 {
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1831 /* Handle drawing alternating row colors if enabled */
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1832 if ((row % 2) == 0)
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1833 {
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1834 if(evencolor)
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1835 {
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1836 [bcell setDrawsBackground:YES];
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1837 [bcell setBackgroundColor:evencolor];
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1838 }
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1839 else
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1840 [bcell setDrawsBackground:NO];
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1841 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
1842 else
1215
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1843 {
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1844 if(oddcolor)
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1845 {
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1846 [bcell setDrawsBackground:YES];
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1847 [bcell setBackgroundColor:oddcolor];
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1848 }
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1849 else
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1850 [bcell setDrawsBackground:NO];
dc8ea09605f7 Can't set the background on Image cells apparently on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1212
diff changeset
1851 }
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
1852 }
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
1853 }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1854 -(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
1855 {
1288
d10969835d2d Changes to allow removing icon on BITMAPORICON container columns on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1279
diff changeset
1856 if(tvcols)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1857 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1858 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
1859 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
1860 {
1288
d10969835d2d Changes to allow removing icon on BITMAPORICON container columns on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1279
diff changeset
1861 if(!input)
d10969835d2d Changes to allow removing icon on BITMAPORICON container columns on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1279
diff changeset
1862 input = [NSNull null];
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
1863 [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
1864 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1865 }
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
1866 }
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
1867 -(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
1868 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1869 if(tvcols)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1870 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1871 int z, start, end;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1872 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
1873
1705
3fa0448d3a7e Fixed a bug in dw_container_delete_row() on Mac and potentially a similar bug in dw_container_delete().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
1874 start = (count * row);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1875 end = start + count;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
1876
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1877 for(z=start;z<end;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1878 {
1705
3fa0448d3a7e Fixed a bug in dw_container_delete_row() on Mac and potentially a similar bug in dw_container_delete().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
1879 [data removeObjectAtIndex:start];
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 [titles removePointerAtIndex:row];
1705
3fa0448d3a7e Fixed a bug in dw_container_delete_row() on Mac and potentially a similar bug in dw_container_delete().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
1882 if(lastAddPoint > 0 && lastAddPoint > row)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1883 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1884 lastAddPoint--;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1885 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1886 }
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
1887 }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1888 -(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
1889 -(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
1890 -(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
1891 -(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
1892 -(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
1893 -(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
1894 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
1895 -(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
1896 -(void)setup
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
1897 {
1774
4cc999e757a3 Check for pointerArrayWithWeakObjects before weakObjectsPointerArray on Mac
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1773
diff changeset
1898 SEL swopa = NSSelectorFromString(@"pointerArrayWithWeakObjects");
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1899
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1900 if(![[NSPointerArray class] respondsToSelector:swopa])
1774
4cc999e757a3 Check for pointerArrayWithWeakObjects before weakObjectsPointerArray on Mac
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1773
diff changeset
1901 swopa = NSSelectorFromString(@"weakObjectsPointerArray");
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1902 if(![[NSPointerArray class] respondsToSelector:swopa])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1903 return;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1904
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1905 IMP iwopa = [[NSPointerArray class] methodForSelector:swopa];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1906
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1907 titles = iwopa([NSPointerArray class], swopa);
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1908 [titles retain];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1909 tvcols = [[[NSMutableArray alloc] init] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1910 data = [[[NSMutableArray alloc] init] retain];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1911 types = [[[NSMutableArray alloc] init] retain];
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
1912
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
1913 [[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
1914 }
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1915 -(NSSize)getsize
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1916 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1917 int cwidth = 0, cheight = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1918
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1919 if(tvcols)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1920 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1921 int z;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1922 int colcount = (int)[tvcols count];
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1923 int rowcount = (int)[self numberOfRowsInTableView:self];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1924
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1925 for(z=0;z<colcount;z++)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1926 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1927 NSTableColumn *column = [tvcols objectAtIndex:z];
1574
ae5e322584cd Use [NSTableColumn width] method to get header width on Mac instead of frame size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1573
diff changeset
1928 int width = [column width];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1929
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1930 if(rowcount > 0)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1931 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1932 int x;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1933
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1934 for(x=0;x<rowcount;x++)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1935 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1936 NSCell *cell = [self preparedCellAtColumn:z row:x];
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1937 int thiswidth = [cell cellSize].width;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1938
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1939 /* If on the first column... add up the heights */
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1940 if(z == 0)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1941 cheight += [cell cellSize].height;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1942
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1943 /* Check the image inside the cell to get its width */
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1944 if([cell isMemberOfClass:[NSImageCell class]])
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1945 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1946 int index = (int)(x * [tvcols count]) + z;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1947 NSImage *image = [data objectAtIndex:index];
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1948 if([image isMemberOfClass:[NSImage class]])
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1949 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1950 thiswidth = [image size].width;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1951 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1952 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
1953
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1954 if(thiswidth > width)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1955 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1956 width = thiswidth;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1957 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1958 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1959 /* If the image is missing default the optimized width to 16. */
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1960 if(!width && [[types objectAtIndex:z] intValue] & DW_CFA_BITMAPORICON)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1961 {
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1962 width = 16;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1963 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1964 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1965 if(width)
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1966 cwidth += width;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1967 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1968 }
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1969 cwidth += 16;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1970 cheight += 16;
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1971 return NSMakeSize(cwidth, cheight);
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
1972 }
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
1973 -(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
1974 {
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
1975 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
1976 {
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
1977 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
1978 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
1979 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
1980
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
1981 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
1982 {
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
1983 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
1984 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
1985 {
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
1986 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
1987 {
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
1988 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
1989 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
1990 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
1991
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
1992 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
1993 {
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
1994 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
1995 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
1996
866
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
1997 /* 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
1998 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
1999 {
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
2000 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
2001 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
2002 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
2003 {
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
2004 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
2005 }
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
2006 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2007
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
2008 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
2009 {
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
2010 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
2011 }
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
2012 }
866
ba9d38b8d0bc Added code to check the image size inside the cell during optimize.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 864
diff changeset
2013 /* 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
2014 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
2015 {
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
2016 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
2017 }
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
2018 /* 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
2019 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
2020 {
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
2021 [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
2022 }
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
2023 }
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
2024 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
2025 {
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
2026 [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
2027 }
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
2028 }
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
2029 }
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
2030 }
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
2031 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2032 -(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
2033 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2034 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
2035
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2036 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
2037 [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
2038
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2039 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
2040 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2041 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
2042 NSTextFieldCell *cell = [tableColumn dataCell];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2043 [cell setTextColor:fgcolor];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2044 }
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2045 }
708
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
2046 -(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
2047 {
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
2048 /* Handler for container class */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2049 _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
2050 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2051 -(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
2052 {
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
2053 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
2054 {
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
2055 _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
2056 }
829
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
2057 [super keyUp:theEvent];
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
2058 }
f7b6c88bac47 Implemented Enter/Return triggering the item enter event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 828
diff changeset
2059
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
2060 -(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
2061 {
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
2062 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
2063
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
2064 /* Handler for column click class */
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
2065 _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
2066 }
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
2067 -(void)selectionChanged:(id)sender
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
2068 {
703
329736825f9b Implemented more of the missing event/signal handlers and other code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 702
diff changeset
2069 /* Handler for container class */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2070 _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
2071 /* 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
2072 _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
2073 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2074 -(NSMenu *)menuForEvent:(NSEvent *)event
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
2075 {
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2076 int row;
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2077 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
2078 row = (int)[self rowAtPoint:where];
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2079 _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
2080 return nil;
659
756015085da7 Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 658
diff changeset
2081 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
2082 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2083 @end
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084
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
2085 /* 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
2086 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
2087 {
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
2088 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
2089 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2090 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
2091 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
2092 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
2093
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
2094 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
2095 index = [node indexOfObject:item];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2096
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
2097 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
2098 {
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
2099 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
2100 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
2101
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
2102 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
2103 {
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
2104 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
2105 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2106
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
2107 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
2108 {
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
2109 _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
2110 [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
2111 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
2112 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
2113 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
2114 }
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
2115 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
2116 {
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
2117 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
2118 [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
2119 _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
2120 }
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
2121 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
2122 _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
2123 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2124 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2125 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
2126 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2127 [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
2128 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2129 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
2130
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2131 /* Subclass for a Tree type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2132 @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
2133 #ifdef BUILDING_FOR_SNOW_LEOPARD
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
2134 <NSOutlineViewDataSource,NSOutlineViewDelegate>
717
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
2135 #endif
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2136 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2137 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
2138 NSTableColumn *treecol;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2139 NSMutableArray *data;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2140 /* 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
2141 * 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
2142 */
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2143 id scrollview;
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2144 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
2145 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2146 -(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
2147 -(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
2148 -(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
2149 -(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
2150 -(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
2151 -(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
2152 -(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
2153 -(void *)userdata;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2154 -(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
2155 -(void)treeSelectionChanged:(id)sender;
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2156 -(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
2157 -(NSScrollView *)scrollview;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2158 -(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
2159 -(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
2160 -(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
2161 -(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
2162 @end
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2163
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2164 @implementation DWTree
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2165 -(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
2166 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2167 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2168
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2169 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
2170 {
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
2171 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
2172 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
2173 [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
2174 [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
2175 [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
2176 [[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
2177 [[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
2178 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2179 return self;
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2180 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2181 -(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
2182 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2183 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
2184 {
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
2185 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
2186 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
2187 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2188 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2189 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2190 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
2191 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2192 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2193 -(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
2194 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2195 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
2196 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2197 -(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
2198 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2199 if(item)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2200 {
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
2201 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
2202 {
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
2203 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
2204 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
2205 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2206 else
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2207 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2208 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
2209 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2210 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2211 else
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2212 {
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2213 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
2214 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2215 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2216 -(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
2217 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2218 if(item)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2219 {
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
2220 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
2221 {
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
2222 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
2223 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
2224 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2225 else
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2226 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2227 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
2228 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2229 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2230 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
2231 }
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
2232 -(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
2233 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
2234 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
2235 {
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
2236 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
2237 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
2238 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
2239 [(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
2240 }
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
2241 }
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2242 -(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
2243 -(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
2244 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2245 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
2246 if(parent)
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2247 {
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
2248 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
2249 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
2250 {
692
bd909322f40d Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 691
diff changeset
2251 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
2252 [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
2253 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2254 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2255 else
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2256 {
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2257 if(!data)
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2258 {
692
bd909322f40d Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 691
diff changeset
2259 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
2260 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2261 }
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
2262 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
2263 {
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
2264 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
2265 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
2266 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
2267 [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
2268 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
2269 [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
2270 }
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
2271 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
2272 {
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
2273 [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
2274 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2275 }
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2276 -(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
2277 -(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
2278 -(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
2279 {
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2280 /* 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
2281 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
2282
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
2283 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
2284 {
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
2285 _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
2286 }
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2287 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2288 -(void)treeItemExpanded:(NSNotification *)notification
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2289 {
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2290 id item = [[notification userInfo ] objectForKey: @"NSObject"];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2291
722
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2292 if(item)
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2293 {
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2294 _event_handler(self, (void *)item, 16);
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2295 }
5a8d5161651d Implemented tree expand event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 721
diff changeset
2296 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2297 -(NSMenu *)menuForEvent:(NSEvent *)event
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2298 {
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2299 int row;
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2300 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
2301 row = (int)[self rowAtPoint:where];
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2302 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
2303 _event_handler(self, (NSEvent *)item, 10);
710
78460ff977c1 Finishing up tree event/signal handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 709
diff changeset
2304 return nil;
709
5a268d5f1cfa Fixes for tree event handling. Still more to come shortly...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 708
diff changeset
2305 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2306 -(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
2307 -(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
2308 -(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
2309 -(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
2310 {
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
2311 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
2312 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
2313 [fgcolor retain];
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2314 [cell setTextColor:fgcolor];
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
2315 }
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
2316 -(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
2317 -(void)dealloc
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2318 {
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2319 UserData *root = userdata;
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2320 _remove_userdata(&root, NULL, TRUE);
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2321 _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
2322 [treecol release];
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
2323 dw_signal_disconnect_by_window(self);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2324 [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
2325 }
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2326 @end
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
2327
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2328 /* Subclass for a Calendar type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2329 @interface DWCalendar : NSDatePicker
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2330 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2331 void *userdata;
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2332 }
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2333 -(void *)userdata;
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2334 -(void)setUserdata:(void *)input;
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2335 @end
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2336
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2337 @implementation DWCalendar
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2338 -(void *)userdata { return userdata; }
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2339 -(void)setUserdata:(void *)input { userdata = input; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
2340 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
655
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2341 @end
27eb39d2577b Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 654
diff changeset
2342
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2343 /* Subclass for a Combobox type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2344 @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
2345 #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
2346 <NSComboBoxDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
2347 #endif
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2348 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2349 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
2350 id clickDefault;
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2351 }
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2352 -(void *)userdata;
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2353 -(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
2354 -(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
2355 -(void)setClickDefault:(id)input;
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2356 @end
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2357
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2358 @implementation DWComboBox
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2359 -(void *)userdata { return userdata; }
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2360 -(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
2361 -(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
2362 -(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
2363 -(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
2364 {
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
2365 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
2366 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2367 [[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
2368 } else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2369 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2370 [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
2371 }
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
2372 }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
2373 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2374 @end
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2375
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
2376 /* 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
2377 /* 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
2378 @interface DWStepper : NSStepper
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2379 {
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
2380 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
2381 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
2382 }
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
2383 -(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
2384 -(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
2385 -(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
2386 -(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
2387 -(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
2388 -(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
2389 @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
2390
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
2391 @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
2392 -(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
2393 -(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
2394 -(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
2395 -(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
2396 -(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
2397 {
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
2398 [super mouseDown:event];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2399 if([[NSApp currentEvent] type] == NSLeftMouseUp)
1302
5fbf384780d1 Simplified the DWStepper class a bit on Mac... although it really needs rewriting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1301
diff changeset
2400 [self mouseUp:event];
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
2401 }
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
2402 -(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
2403 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2404 [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
2405 _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
2406 }
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
2407 @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
2408
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2409 /* Subclass for a Spinbutton type */
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2410 @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
2411 #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
2412 <NSTextFieldDelegate>
17923b931393 Fixes for building for MacOS 10.5 and PPC
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 715
diff changeset
2413 #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
2414 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2415 void *userdata;
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2416 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
2417 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
2418 id clickDefault;
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2419 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2420 -(id)init;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2421 -(void *)userdata;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2422 -(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
2423 -(NSTextField *)textfield;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2424 -(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
2425 -(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
2426 -(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
2427 @end
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2428
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2429 @implementation DWSpinButton
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2430 -(id)init
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2431 {
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2432 self = [super init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2433
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2434 if(self)
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2435 {
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
2436 textfield = [[[NSTextField alloc] init] autorelease];
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2437 [self addSubview:textfield];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
2438 stepper = [[[DWStepper alloc] init] autorelease];
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2439 [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
2440 [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
2441 [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
2442 [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
2443 [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
2444 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2445 return self;
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2446 }
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2447 -(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
2448 -(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
2449 -(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
2450 -(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
2451 -(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
2452 {
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
2453 [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
2454 [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
2455 _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
2456 }
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
2457 -(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
2458 -(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
2459 {
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
2460 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
2461 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2462 [[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
2463 }
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2464 else
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2465 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2466 [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
2467 }
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
2468 }
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
2469 -(void)performClick:(id)sender { [textfield performClick:sender]; }
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
2470 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2471 @end
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
2472
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
2473 /* 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
2474 * 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
2475 * 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
2476 */
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
2477 @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
2478 @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
2479
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
2480 @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
2481 @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
2482
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 /* 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
2484 */
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
2485 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
2486 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2487 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
2488
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2489 new->message = message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2490 new->window = window;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2491 new->id = msgid;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2492 new->signalfunction = signalfunction;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2493 new->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2494 new->next = NULL;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2495
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2496 if (!Root)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2497 Root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2498 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2499 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2500 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2501 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2502 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2503 if(tmp->message == message &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2504 tmp->window == window &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2505 tmp->id == msgid &&
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2506 tmp->signalfunction == signalfunction)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2507 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2508 tmp->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2509 free(new);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2510 return;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2511 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2512 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2513 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2514 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2515 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2516 prev->next = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2517 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2518 Root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2519 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 /* 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
2523 ULONG _findsigmessage(char *signame)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2525 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2526
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2527 for(z=0;z<SIGNALMAX;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2528 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2529 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2530 return SignalTranslate[z].message;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2531 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2532 return 0L;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 unsigned long _foreground = 0xAAAAAA, _background = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536
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
2537 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
2538 {
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
2539 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
2540
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
2541 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
2542 {
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
2543 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
2544
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
2545 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
2546 {
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
2547 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
2548
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
2549 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
2550 {
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
2551 _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
2552 }
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
2553 }
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
2554 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
2555 {
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
2556 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
2557 {
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
2558 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
2559 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
2560 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
2561 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
2562
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
2563 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
2564 {
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
2565 [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
2566 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2567
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
2568 /* 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
2569 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
2570 {
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
2571 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
2572 {
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
2573 [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
2574 _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
2575 }
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
2576 }
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
2577 }
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
2578 /* 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
2579 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
2580 {
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
2581 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
2582 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
2583 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
2584
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
2585 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
2586 {
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
2587 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
2588 _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
2589 }
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
2590 }
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
2591 /* 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
2592 * 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
2593 */
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
2594 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
2595 {
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
2596 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
2597 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
2598 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
2599
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
2600 /* 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
2601 _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
2602 }
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
2603 }
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
2604 }
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
2605 }
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
2606
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 /* 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
2608 * and does expansion as necessary.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 */
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2610 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2611 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2612 /* Current item position */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2613 int z, currentx = thisbox->pad, currenty = thisbox->pad;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2614 /* Used x, y and padding maximum values...
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2615 * These will be used to find the widest or
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2616 * tallest items in a box.
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2617 */
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
2618 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
2619 int upymax = 0, upxmax = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2620
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2621 /* Reset the box sizes */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2622 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = 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
2623
798
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2624 /* Handle special groupbox case */
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2625 if(thisbox->grouphwnd)
1b0a0775ec19 Ok... groupbox calculation fix try #2!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 797
diff changeset
2626 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2627 /* Only calculate the size on the first pass...
1442
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1438
diff changeset
2628 * use the cached values on second.
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2629 */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2630 if(pass == 1)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2631 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2632 DWGroupBox *groupbox = thisbox->grouphwnd;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2633 NSSize borderSize = [groupbox borderSize];
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2634 NSRect titleRect;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2635
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2636 if(borderSize.width == 0 || borderSize.height == 0)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2637 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2638 borderSize = [groupbox initBorder];
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2639 }
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2640 /* Get the title size for a more accurate groupbox padding size */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2641 titleRect = [groupbox titleRect];
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2642
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2643 thisbox->grouppadx = borderSize.width;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2644 thisbox->grouppady = borderSize.height + titleRect.size.height;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2645 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2646
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2647 thisbox->minwidth += thisbox->grouppadx;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2648 thisbox->usedpadx += thisbox->grouppadx;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2649 thisbox->minheight += thisbox->grouppady;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2650 thisbox->usedpady += thisbox->grouppady;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2651 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2652
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2653 /* Count up all the space for all items in the box */
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
2654 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
2655 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2656 int itempad, itemwidth, itemheight;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2657
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
2658 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
2659 {
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
2660 id box = thisbox->items[z].hwnd;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2661 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
2662
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 if(tmp)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2665 /* On the first pass calculate the box contents */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2666 if(pass == 1)
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 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2668 (*depth)++;
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2669
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2670 /* Save the newly calculated values on the box */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2671 _resize_box(tmp, depth, x, y, pass);
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2672
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2673 /* Duplicate the values in the item list for use below */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2674 thisbox->items[z].width = tmp->minwidth;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2675 thisbox->items[z].height = tmp->minheight;
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2676
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2677 /* If the box has no contents but is expandable... default the size to 1 */
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2678 if(!thisbox->items[z].width && thisbox->items[z].hsize)
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2679 thisbox->items[z].width = 1;
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2680 if(!thisbox->items[z].height && thisbox->items[z].vsize)
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2681 thisbox->items[z].height = 1;
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2682
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2683 (*depth)--;
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
2684 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685 }
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
2686 }
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2687
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2688 /* Precalculate these values, since they will
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2689 * be used used repeatedly in the next section.
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2690 */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2691 itempad = thisbox->items[z].pad * 2;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2692 itemwidth = thisbox->items[z].width + itempad;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2693 itemheight = thisbox->items[z].height + itempad;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2694
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2695 /* Calculate the totals and maximums */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2696 if(thisbox->type == DW_VERT)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2697 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2698 if(itemwidth > uxmax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2699 uxmax = itemwidth;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2700
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2701 if(thisbox->items[z].hsize != 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
2702 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2703 if(itemwidth > upxmax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2704 upxmax = itemwidth;
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
2705 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 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
2707 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2708 if(itempad > upxmax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2709 upxmax = itempad;
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
2710 }
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2711 thisbox->minheight += itemheight;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2712 if(thisbox->items[z].vsize != SIZEEXPAND)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2713 thisbox->usedpady += itemheight;
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
2714 else
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2715 thisbox->usedpady += itempad;
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
2716 }
43a5b3c78c41 Two fixes... the first is on 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 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
2718 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2719 if(itemheight > uymax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2720 uymax = itemheight;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2721 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
2722 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2723 if(itemheight > upymax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2724 upymax = itemheight;
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 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2726 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
2727 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2728 if(itempad > upymax)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2729 upymax = itempad;
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
2730 }
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2731 thisbox->minwidth += itemwidth;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2732 if(thisbox->items[z].hsize != SIZEEXPAND)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2733 thisbox->usedpadx += itemwidth;
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
2734 else
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2735 thisbox->usedpadx += itempad;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2736 }
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2737 }
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2738
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2739 /* Add the maximums which were calculated in the previous loop */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2740 thisbox->minwidth += uxmax;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2741 thisbox->minheight += uymax;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2742 thisbox->usedpadx += upxmax;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2743 thisbox->usedpady += upymax;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2744
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2745 /* The second pass is for actual placement. */
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
2746 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
2747 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2748 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
2749 {
43a5b3c78c41 Two fixes... the first is on 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 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
2751 int width = thisbox->items[z].width;
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2752 int itempad = thisbox->items[z].pad * 2;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2753 int thispad = thisbox->pad * 2;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2754
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2755 /* Calculate the new sizes */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2756 if(thisbox->items[z].hsize == SIZEEXPAND)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2757 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2758 if(thisbox->type == DW_HORZ)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2759 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2760 int expandablex = thisbox->minwidth - thisbox->usedpadx;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2761
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2762 if(expandablex)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2763 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2764 }
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2765 else
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2766 width = x - (itempad + thispad + thisbox->grouppadx);
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2767 }
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2768 if(thisbox->items[z].vsize == SIZEEXPAND)
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2769 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2770 if(thisbox->type == DW_VERT)
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
2771 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2772 int expandabley = thisbox->minheight - thisbox->usedpady;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2773
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2774 if(expandabley)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2775 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
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
2776 }
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2777 else
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2778 height = y - (itempad + thispad + thisbox->grouppady);
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2779 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2780
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2781 /* If the calculated size is valid... */
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2782 if(height > 0 && width > 0)
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2783 {
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2784 int pad = thisbox->items[z].pad;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2785 NSView *handle = thisbox->items[z].hwnd;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2786 NSPoint point;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2787 NSSize size;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2788
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
2789 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
2790 point.y = currenty + pad;
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2791 size.width = width;
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2792 size.height = height;
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
2793 [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
2794 [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
2795
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
2796 /* 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
2797 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
2798 {
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
2799 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
2800 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
2801
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
2802 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
2803 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2804 (*depth)++;
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2805 _resize_box(tmp, depth, width, height, pass);
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
2806 (*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
2807 }
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2808 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
2809
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
2810 /* 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
2811 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
2812 {
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
2813 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
2814 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
2815 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
2816
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
2817 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
2818 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2819 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
2820 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
2821 _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
2822 _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
2823 }
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
2824 }
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
2825 /* 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
2826 * 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
2827 */
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2828 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
2829 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2830 int depth = 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
2831 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
2832 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
2833 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
2834 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
2835
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
2836 /* Get the required space for the box */
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2837 _resize_box(thisbox, &depth, x, y, 1);
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2838
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2839 if(contentsize.width < thisbox->minwidth)
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
2840 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2841 contentsize.width = thisbox->minwidth;
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
2842 }
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2843 if(contentsize.height < thisbox->minheight)
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
2844 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2845 contentsize.height = thisbox->minheight;
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
2846 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2847 [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
2848
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
2849 /* 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
2850 _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
2851 _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
2852 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2853 /* 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
2854 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
2855 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2856 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
2857 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
2858 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
2859 [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
2860 [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
2861 [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
2862 [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
2863 }
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2864 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
2865 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2866 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
2867 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
2868 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
2869
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2870 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
2871 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2872 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
2873 [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
2874 }
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
2875 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
2876 {
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
2877 [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
2878 }
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
2879 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2880
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
2881 /* Advance the current position in the box */
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
2882 if(thisbox->type == DW_HORZ)
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2883 currentx += width + (pad * 2);
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
2884 if(thisbox->type == DW_VERT)
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2885 currenty += height + (pad * 2);
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
2886 }
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
2887 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2888 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 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
2892 {
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
2893 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
2894 {
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2895 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
2896 {
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2897 int depth = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2898
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
2899 /* Calculate space requirements */
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2900 _resize_box(thisbox, &depth, x, y, 1);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
2901
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
2902 /* Finally place all the boxes and controls */
1437
a50e8b486a1a Initial layout engine 2.0 for the Mac... Windows and OS/2 may not compile until
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1435
diff changeset
2903 _resize_box(thisbox, &depth, x, y, 2);
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
2904 }
43a5b3c78c41 Two fixes... the first is on the fly calculation of groupbox border size. This also fixes some initial window issues...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 927
diff changeset
2905 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2908 NSMenu *_generate_main_menu()
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2909 {
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
2910 NSString *applicationName = nil;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2911
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
2912 /* 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
2913 #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
2914 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
2915 #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
2916 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
2917 {
eba6ab48c952 Runtime Snow Leopard checks where possible and visual fix for Leopard status text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 749
diff changeset
2918 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
2919 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2920
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2921 /* Create the main menu */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2922 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
2923
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2924 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2925 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
2926
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2927 [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
2928
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2929 /* Setup the Application menu */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2930 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
2931 action:@selector(orderFrontStandardAboutPanel:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2932 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2933 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2934
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2935 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2936
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2937 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2938 action:NULL
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2939 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2940 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2941 [menu setSubmenu:servicesMenu forItem:item];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2942 [DWApp setServicesMenu:servicesMenu];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2943
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2944 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2945
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2946 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName]
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2947 action:@selector(hide:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2948 keyEquivalent:@"h"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2949 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2950
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2951 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2952 action:@selector(hideOtherApplications:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2953 keyEquivalent:@"h"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2954 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2955 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2956
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2957 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2958 action:@selector(unhideAllApplications:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2959 keyEquivalent:@""];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2960 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2961
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2962 [menu addItem:[NSMenuItem separatorItem]];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2963
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2964 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName]
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2965 action:@selector(terminate:)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2966 keyEquivalent:@"q"];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2967 [item setTarget:DWApp];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
2968
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2969 [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
2970
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
2971 return mainMenu;
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2972 }
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2973
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
2974 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 * 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
2976 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 void API dw_main(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
2979 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
2980 DWThread = dw_thread_id();
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2981 /* Make sure any queued redraws are handled */
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
2982 _dw_redraw(0, FALSE);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 [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
2984 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
2985 dw_mutex_unlock(DWRunMutex);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2989 * Causes running dw_main() to return.
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2990 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2991 void API dw_main_quit(void)
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2992 {
1529
92bed442620a Didn't notice that [NSApplication stop] took a sender parameter on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
2993 [DWApp stop:nil];
1558
9c5d3ac5bec5 Attempted fix on Mac for 10.5 menu event delay issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1557
diff changeset
2994 _dw_wakeup_app();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2995 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2996
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1527
diff changeset
2997 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 * 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
2999 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 * 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
3001 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 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
3003 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3004 DWTID curr = pthread_self();
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3005
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3006 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
3007 {
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3008 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
3009 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3010
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3011 if(orig == (DWTID)-1)
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3012 {
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
3013 dw_mutex_lock(DWRunMutex);
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3014 DWThread = curr;
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3015 }
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1446
diff changeset
3016 /* Process any pending events */
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
3017 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
3018 {
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
3019 /* Just loop */
695
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3020 }
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3021 if(orig == (DWTID)-1)
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3022 {
3b17111499bf Minor updates to the last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 694
diff changeset
3023 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
3024 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
3025 }
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3026 }
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3027 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
3028 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3029 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
3030 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3033 /* 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
3034 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
3035 {
694
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3036 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
3037 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
3038 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
3039 dequeue:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3040 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
3041 {
130ca42c4ae3 Reimplementation of dw_main_iteration and dw_main_sleep that actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 693
diff changeset
3042 [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
3043 [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
3044 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
3045 }
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
3046 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 /*
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3050 * 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
3051 */
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3052 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
3053 {
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
3054 DWTID curr = pthread_self();
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3055
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
3056 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
3057 {
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
3058 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
3059 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
3060 _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
3061 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
3062 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
3063 }
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
3064 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
3065 {
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
3066 _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
3067 }
700
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3068 }
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3069
7953f0471e4d Some cleanups for the run loop iteration and thread system.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 699
diff changeset
3070 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071 * 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
3072 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3073 * 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
3074 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 void API dw_exit(int exitcode)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 {
1559
bc3a11fe9a46 Don't use _dw_pool_drain() in dw_exit() on Mac... that drains and recreates the pool.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1558
diff changeset
3077 #if !defined(GARBAGE_COLLECT)
bc3a11fe9a46 Don't use _dw_pool_drain() in dw_exit() on Mac... that drains and recreates the pool.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1558
diff changeset
3078 pool = pthread_getspecific(_dw_pool_key);
bc3a11fe9a46 Don't use _dw_pool_drain() in dw_exit() on Mac... that drains and recreates the pool.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1558
diff changeset
3079 [pool drain];
bc3a11fe9a46 Don't use _dw_pool_drain() in dw_exit() on Mac... that drains and recreates the pool.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1558
diff changeset
3080 #endif
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3081 exit(exitcode);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085 * 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
3086 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 * ptr: Pointer to dynamic windows allocated
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 * memory to be free()'d.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 void API dw_free(void *ptr)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 free(ptr);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 * 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
3097 * 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
3098 * OS/2 and Windows).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 char *dw_user_dir(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 {
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3102 static char _user_dir[PATH_MAX+1] = { 0 };
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3103
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3104 if(!_user_dir[0])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3105 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3106 char *home = getenv("HOME");
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3107
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3108 if(home)
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3109 strncpy(_user_dir, home, PATH_MAX);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3110 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3111 strcpy(_user_dir, "/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3112 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3113 return _user_dir;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3117 * Returns a pointer to a static buffer which containes the
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3118 * private application data directory.
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3119 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1383
diff changeset
3120 char * API dw_app_dir(void)
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3121 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3122 return _dw_bundle_path;
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3123 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3124
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
3125 /*
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3126 * Displays a debug message on the console...
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3127 * Parameters:
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3128 * format: printf style format string.
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3129 * ...: Additional variables for use in the format.
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3130 */
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3131 void API dw_debug(char *format, ...)
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3132 {
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3133 va_list args;
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3134 char outbuf[1025] = {0};
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3135
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3136 va_start(args, format);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3137 vsnprintf(outbuf, 1024, format, args);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3138 va_end(args);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3139
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3140 NSLog(@"%s", outbuf);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3141 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3142
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3143 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 * 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
3145 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 * 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
3147 * 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
3148 * format: printf style format string.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 * ...: 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
3150 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 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
3152 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3153 int iResponse;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3154 NSString *button1 = @"OK";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3155 NSString *button2 = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3156 NSString *button3 = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3157 va_list args;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3158 char outbuf[1025] = {0};
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3159
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3160 va_start(args, format);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
3161 vsnprintf(outbuf, 1024, format, args);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3162 va_end(args);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3163
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3164 if(flags & DW_MB_OKCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3165 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3166 button2 = @"Cancel";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3167 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3168 else if(flags & DW_MB_YESNO)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3169 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3170 button1 = @"Yes";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3171 button2 = @"No";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3172 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3173 else if(flags & DW_MB_YESNOCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3174 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3175 button1 = @"Yes";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3176 button2 = @"No";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3177 button3 = @"Cancel";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3178 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3179
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3180 if(flags & DW_MB_ERROR)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3181 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3182 iResponse = (int)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3183 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3184 [ 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
3185 button1, button2, button3);
936
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3186 }
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3187 else if(flags & DW_MB_INFORMATION)
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3188 {
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3189 iResponse = (int)
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3190 NSRunInformationalAlertPanel([ NSString stringWithUTF8String:title ],
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3191 [ 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
3192 button1, button2, button3);
936
4be0c9f963f8 Implement informational messagebox style on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 935
diff changeset
3193 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3194 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3195 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3196 iResponse = (int)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3197 NSRunAlertPanel([ NSString stringWithUTF8String:title ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3198 [ NSString stringWithUTF8String:outbuf ],
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3199 button1, button2, button3);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3200 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3201
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3202 switch(iResponse)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3203 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3204 case NSAlertDefaultReturn: /* user pressed OK */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3205 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3206 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3207 return DW_MB_RETURN_YES;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3208 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3209 return DW_MB_RETURN_OK;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3210 case NSAlertAlternateReturn: /* user pressed Cancel */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3211 if(flags & DW_MB_OKCANCEL)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3212 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3213 return DW_MB_RETURN_CANCEL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3214 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3215 return DW_MB_RETURN_NO;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3216 case NSAlertOtherReturn: /* user pressed the third button */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3217 return DW_MB_RETURN_CANCEL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3218 case NSAlertErrorReturn: /* an error occurred */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3219 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3220 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3221 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3222 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225 * 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
3226 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3227 * title: Title bar text for dialog.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 * 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
3229 * ext: Default file extention.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 * 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
3231 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 * 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
3233 * the file path on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234 *
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 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
3237 {
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3238 char temp[PATH_MAX+1];
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3239 char *file = NULL, *path = NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3240 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3241
1301
7527fb644bc0 Only use default directory and filename options for Mac 10.6 and higher.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1298
diff changeset
3242 /* Figure out path information...
7527fb644bc0 Only use default directory and filename options for Mac 10.6 and higher.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1298
diff changeset
3243 * These functions are only support in Snow Leopard and later...
7527fb644bc0 Only use default directory and filename options for Mac 10.6 and higher.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1298
diff changeset
3244 */
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
3245 if(defpath && *defpath && DWOSMinor > 5)
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3246 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3247 struct stat buf;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3248
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3249 /* Get an absolute path */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3250 if(!realpath(defpath, temp))
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3251 strcpy(temp, defpath);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3252
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3253 /* Check if the defpath exists */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3254 if(stat(temp, &buf) == 0)
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3255 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3256 /* Can be a directory or file */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3257 if(buf.st_mode & S_IFDIR)
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3258 path = temp;
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3259 else
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3260 file = temp;
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3261 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3262 /* If it wasn't a directory... check if there is a path */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3263 if(!path && strchr(temp, '/'))
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3264 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3265 unsigned long x = strlen(temp) - 1;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3266
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3267 /* Trim off the filename */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3268 while(x > 0 && temp[x] != '/')
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3269 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3270 x--;
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3271 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3272 if(temp[x] == '/')
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3273 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3274 temp[x] = 0;
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3275 /* Check to make sure the trimmed piece is a directory */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3276 if(stat(temp, &buf) == 0)
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3277 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3278 if(buf.st_mode & S_IFDIR)
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3279 {
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3280 /* We now have it split */
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3281 path = temp;
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3282 file = &temp[x+1];
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3283 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3284 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3285 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3286 }
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3287 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3288
825
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3289 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
3290 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3291 /* Create the File Open Dialog class. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3292 NSOpenPanel* openDlg = [NSOpenPanel openPanel];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3293
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3294 if(path)
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3295 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3296 SEL ssdu = NSSelectorFromString(@"setDirectoryURL");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3297
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3298 if([openDlg respondsToSelector:ssdu])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3299 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3300 IMP isdu = [openDlg methodForSelector:ssdu];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3301 isdu(openDlg, ssdu, [NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]);
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3302 }
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3303 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3304
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3305 /* 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
3306 if(flags == DW_FILE_OPEN)
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3307 {
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3308 [openDlg setCanChooseFiles:YES];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3309 [openDlg setCanChooseDirectories:NO];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3310 }
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3311 else
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3312 {
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3313 [openDlg setCanChooseFiles:NO];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3314 [openDlg setCanChooseDirectories:YES];
8a2e3138e1e4 Implemented DW_DIRECTORY_OPEN on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 821
diff changeset
3315 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3316
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3317 /* Handle file types */
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
3318 if(ext && *ext)
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3319 {
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
3320 NSArray* fileTypes = [[[NSArray alloc] initWithObjects:[NSString stringWithUTF8String:ext], nil] autorelease];
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3321 [openDlg setAllowedFileTypes:fileTypes];
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3322 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3323
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3324 /* Disable multiple selection */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3325 [openDlg setAllowsMultipleSelection:NO];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3326
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3327 /* Display the dialog. If the OK button was pressed,
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3328 * process the files.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3329 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3330 if([openDlg runModal] == NSOKButton)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3331 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3332 /* Get an array containing the full filenames of all
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3333 * files and directories selected.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3334 */
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3335 NSArray *files = [openDlg URLs];
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3336 NSString *fileName = [[files objectAtIndex:0] path];
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3337 if(fileName)
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3338 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3339 char *ret = strdup([ fileName UTF8String ]);
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3340 DW_LOCAL_POOL_OUT;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3341 return ret;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3342 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3343 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3344 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3345 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3346 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3347 /* Create the File Save Dialog class. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3348 NSSavePanel* saveDlg = [NSSavePanel savePanel];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3349
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3350 if(path)
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3351 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3352 SEL ssdu = NSSelectorFromString(@"setDirectoryURL");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3353
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3354 if([saveDlg respondsToSelector:ssdu])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3355 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3356 IMP isdu = [saveDlg methodForSelector:ssdu];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3357 isdu(saveDlg, ssdu, [NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]);
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3358 }
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3359 }
1298
79db0563c7c2 Code to split the file and path apart on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1296
diff changeset
3360 if(file)
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3361 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3362 SEL ssnfsv = NSSelectorFromString(@"setNameFieldStringValue");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3363
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3364 if([saveDlg respondsToSelector:ssnfsv])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3365 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3366 IMP isnfsv = [saveDlg methodForSelector:ssnfsv];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3367 isnfsv(saveDlg, ssnfsv, [NSString stringWithUTF8String:file]);
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3368 }
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3369 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3370
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3371 /* Enable the creation of directories in the dialog. */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3372 [saveDlg setCanCreateDirectories:YES];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3373
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3374 /* Handle file types */
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
3375 if(ext && *ext)
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3376 {
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
3377 NSArray* fileTypes = [[[NSArray alloc] initWithObjects:[NSString stringWithUTF8String:ext], nil] autorelease];
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3378 [saveDlg setAllowedFileTypes:fileTypes];
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3379 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3380
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3381 /* Display the dialog. If the OK button was pressed,
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3382 * process the files.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3383 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3384 if([saveDlg runModal] == NSFileHandlingPanelOKButton)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3385 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3386 /* Get an array containing the full filenames of all
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3387 * files and directories selected.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3388 */
1296
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3389 NSString* fileName = [[saveDlg URL] path];
40d62db77c90 Added some defpath support and extension support to the Mac dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
3390 if(fileName)
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3391 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3392 char *ret = strdup([ fileName UTF8String ]);
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3393 DW_LOCAL_POOL_OUT;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3394 return ret;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3395 }
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3396 }
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3397 }
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
3398 DW_LOCAL_POOL_OUT;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3399 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 * 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
3404 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 * None.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 * 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
3408 * be converted to text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 char *dw_clipboard_get_text()
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3412 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3413 NSString *str = [pasteboard stringForType:NSStringPboardType];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3414 if(str != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3415 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3416 return strdup([ str UTF8String ]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3417 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3418 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 * 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
3423 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 * Text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 */
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
3426 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
3427 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3428 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3429 SEL scc = NSSelectorFromString(@"clearContents");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3430
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3431 if([pasteboard respondsToSelector:scc])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3432 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3433 IMP icc = [pasteboard methodForSelector:scc];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
3434 icc(pasteboard, scc);
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
3435 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3436
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3437 [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
3438 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 * Allocates and initializes a dialog struct.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 * 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
3445 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 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
3447 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3448 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
3449
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3450 if(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3451 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3452 tmp->eve = dw_event_new();
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3453 dw_event_reset(tmp->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3454 tmp->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3455 tmp->done = FALSE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3456 tmp->result = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3457 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3458 return tmp;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 * 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
3463 * initial called of dw_dialog_wait().
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465 * 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
3466 * 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
3467 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 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
3469 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3470 dialog->result = result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3471 dw_event_post(dialog->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3472 dialog->done = TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3473 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3476 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 * 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
3478 * 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
3479 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 * 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
3481 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482 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
3483 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3484 void *tmp;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
3485
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3486 while(!dialog->done)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3487 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3488 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3489 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3490 dw_event_close(&dialog->eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3491 tmp = dialog->result;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3492 free(dialog);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3493 return tmp;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497 * 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
3498 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 * 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
3500 * 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
3501 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 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
3503 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3504 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
3505 DW_MUTEX_LOCK;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3506 DWBox *view = [[DWBox alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3507 Box *newbox = [view box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3508 memset(newbox, 0, sizeof(Box));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3509 newbox->pad = pad;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3510 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
3511 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
3512 return view;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 * 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
3517 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 * 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
3519 * 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
3520 * 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
3521 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 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
3523 {
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
3524 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
3525 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
3526 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
3527
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
3528 [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
3529 [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
3530 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
3531 [groupbox setContentView:thisbox];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3532 [thisbox autorelease];
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
3533 return groupbox;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3536 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3537 * Create a new scrollable Box to be packed.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3538 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3539 * 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
3540 * 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
3541 */
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
3542 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
3543 {
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3544 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
3545 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
3546 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
3547 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
3548 [scrollbox setHasVerticalScroller:YES];
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3549 [scrollbox setHasHorizontalScroller:YES];
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3550 [scrollbox setBorderType:NSNoBorder];
838
8e0405435d0a Minor scrollbox fixes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 837
diff changeset
3551 [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
3552 [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
3553 [scrollbox setDocumentView:tmpbox];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3554 [tmpbox autorelease];
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
3555 return scrollbox;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3556 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3557
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3558 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3559 * 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
3560 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3561 * handle: Handle to the scrollbox to be queried.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3562 * orient: The vertical or horizontal scrollbar.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3563 */
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
3564 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
3565 {
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
3566 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
3567 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
3568 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
3569 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
3570 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
3571 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
3572 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
3573 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3574 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
3575 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
3576 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3577 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
3578 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3579 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
3580 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
3581 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3582 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
3583 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3584 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
3585 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3586 return val;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3587 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3588
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3589 /*
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3590 * 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
3591 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3592 * handle: Handle to the scrollbox to be queried.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3593 * orient: The vertical or horizontal scrollbar.
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3594 */
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3595 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
3596 {
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
3597 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
3598 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
3599 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
3600 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
3601 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3602 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
3603 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3604 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
3605 {
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3606 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
3607 }
5103d132c3cd Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 840
diff changeset
3608 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
3609 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
3610
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3611 /* Return the handle to the text object */
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3612 id _text_handle(id object)
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3613 {
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3614 if([object isMemberOfClass:[ DWSpinButton class]])
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3615 {
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3616 DWSpinButton *spinbutton = object;
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3617 object = [spinbutton textfield];
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3618 }
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3619 if([object isMemberOfClass:[ NSBox class]])
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3620 {
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3621 NSBox *box = object;
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3622 id content = [box contentView];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3623
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3624 if([content isMemberOfClass:[ DWText class]])
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3625 {
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3626 object = content;
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3627 }
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3628 }
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3629 return object;
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3630 }
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3631
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3632 /* Internal function to calculate the widget's required size..
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3633 * These are the general rules for widget sizes:
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3634 *
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1533
diff changeset
3635 * Render/Unspecified: 1x1
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1553
diff changeset
3636 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3637 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3638 * Spinbutton: 50x(maxfontheight)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3639 * Text/Status: (textwidth)x(textheight)
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
3640 * Ranged: 100x14 or 14x100 for vertical.
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
3641 * Buttons/Bitmaps: Size of text or image and border.
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
3642 */
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3643 void _control_size(id handle, int *width, int *height)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3644 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3645 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3646 NSString *nsstr = nil;
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3647 id object = _text_handle(handle);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3648
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3649 /* Handle all the different button types */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3650 if([ object isKindOfClass:[ NSButton class ] ])
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3651 {
1420
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3652 switch([object buttonType])
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3653 {
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3654 case NSSwitchButton:
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3655 case NSRadioButton:
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3656 extrawidth = 24;
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3657 extraheight = 4;
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3658 nsstr = [object title];
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3659 break;
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3660 default:
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3661 {
1420
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3662 NSImage *image = [object image];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3663
1420
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3664 if(image)
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3665 {
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3666 /* Image button */
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3667 NSSize size = [image size];
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3668 thiswidth = (int)size.width;
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3669 thisheight = (int)size.height;
1432
6aa94c8a91de Bordered bitmap buttons need extra padding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3670 if([object isBordered])
6aa94c8a91de Bordered bitmap buttons need extra padding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3671 {
6aa94c8a91de Bordered bitmap buttons need extra padding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3672 extrawidth = 4;
6aa94c8a91de Bordered bitmap buttons need extra padding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3673 extraheight = 4;
6aa94c8a91de Bordered bitmap buttons need extra padding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
3674 }
1420
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3675 }
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3676 else
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3677 {
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3678 /* Text button */
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3679 nsstr = [object title];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3680
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3681 if([object isBordered])
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3682 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3683 extrawidth = 30;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3684 extraheight = 8;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3685 }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3686 else
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3687 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3688 extrawidth = 8;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3689 extraheight = 4;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3690 }
1420
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3691 }
fabf23bdc7fb New Mac image button handling code was catching checkboxes/radiobuttons as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1419
diff changeset
3692 break;
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3693 }
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3694 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3695 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3696 /* If the control is an entryfield set width to 150 */
1791
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3697 else if([object isKindOfClass:[ NSTextField class ]])
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3698 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3699 NSFont *font = [object font];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3700
1791
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3701 if([object isEditable])
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3702 {
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3703 /* Spinbuttons don't need to be as wide */
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3704 if([object isMemberOfClass:[ DWSpinButton class]])
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3705 thiswidth = 50;
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3706 else
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3707 thiswidth = 150;
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3708 /* Spinbuttons don't need to be as wide */
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3709 if([object isMemberOfClass:[ DWComboBox class]])
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3710 extraheight = 4;
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3711 }
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3712 else
1791
ed8851658015 Set status text fields in the test program to auto height... because they were too small on Mac.... this caused me to notice a bug in the calculation of (status) text widgets when the text is empty; this also contains a fix for that bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1788
diff changeset
3713 nsstr = [object stringValue];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3714
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3715 if(font)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3716 thisheight = (int)[font boundingRectForFont].size.height;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3717 }
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3718 /* Handle the ranged widgets */
1457
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3719 else if([ object isMemberOfClass:[DWPercent class] ] ||
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3720 [ object isMemberOfClass:[DWSlider class] ])
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3721 {
1457
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3722 thiswidth = 100;
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3723 thisheight = 20;
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3724 }
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3725 /* Handle the ranged widgets */
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3726 else if([ object isMemberOfClass:[DWScrollbar class] ])
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3727 {
c22477fe7347 Split out scrollbars from the rest of the ranged widgets on Mac... the others require extra size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1453
diff changeset
3728 if([object vertical])
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3729 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3730 thiswidth = 14;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3731 thisheight = 100;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3732 }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3733 else
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3734 {
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3735 thiswidth = 100;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3736 thisheight = 14;
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3737 }
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3738 }
1421
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3739 /* Handle bitmap size */
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3740 else if([ object isMemberOfClass:[NSImageView class] ])
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3741 {
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3742 NSImage *image = [object image];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3743
1421
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3744 if(image)
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3745 {
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3746 NSSize size = [image size];
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3747 thiswidth = (int)size.width;
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3748 thisheight = (int)size.height;
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3749 }
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
3750 }
1533
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3751 /* Handle calendar */
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3752 else if([ object isMemberOfClass:[DWCalendar class] ])
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3753 {
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3754 NSCell *cell = [object cell];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3755
1533
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3756 if(cell)
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3757 {
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3758 NSSize size = [cell cellSize];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3759
1533
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3760 thiswidth = size.width;
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3761 thisheight = size.height;
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3762 }
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3763 }
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3764 /* MLE and Container */
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3765 else if([ object isMemberOfClass:[DWMLE class] ] ||
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3766 [ object isMemberOfClass:[DWContainer class] ])
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3767 {
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3768 NSSize size;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3769
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3770 if([ object isMemberOfClass:[DWMLE class] ])
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3771 {
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3772 NSScrollView *sv = [object scrollview];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3773 NSSize frame = [sv frame].size;
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3774 BOOL hscroll = [sv hasHorizontalScroller];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3775
1552
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3776 /* Make sure word wrap is off for the first part */
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3777 if(!hscroll)
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3778 {
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3779 [[object textContainer] setWidthTracksTextView:NO];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3780 [[object textContainer] setContainerSize:[object maxSize]];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3781 [object setHorizontallyResizable:YES];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3782 [sv setHasHorizontalScroller:YES];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3783 }
1552
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3784 /* Size the text view to fit */
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3785 [object sizeToFit];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3786 size = [object bounds].size;
1552
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3787 size.width += 2.0;
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3788 size.height += 2.0;
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3789 /* Re-enable word wrapping if it was on */
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3790 if(!hscroll)
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3791 {
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3792 [[object textContainer] setWidthTracksTextView:YES];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3793 [sv setHasHorizontalScroller:NO];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3794
1553
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3795 /* If the un wrapped it is beyond the bounds... */
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3796 if(size.width > _DW_SCROLLED_MAX_WIDTH)
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3797 {
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3798 NSSize max = [object maxSize];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3799
1553
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3800 /* Set the max size to the limit */
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3801 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)];
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3802 /* Recalculate the size */
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3803 [object sizeToFit];
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3804 size = [object bounds].size;
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3805 size.width += 2.0;
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3806 size.height += 2.0;
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3807 [object setMaxSize:max];
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3808 }
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3809 }
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3810 [sv setFrameSize:frame];
1552
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3811 /* Take into account the horizontal scrollbar */
1553
46a2123ff570 Cleanup of the previous commits on Mac, don't do more calculations than we need to.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1552
diff changeset
3812 if(hscroll && size.width > _DW_SCROLLED_MAX_WIDTH)
1552
f00f91d15cbf Added additional code to MLE calculations on Mac to take into account the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1551
diff changeset
3813 size.height += 16.0;
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3814 }
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3815 else
1573
d6e17c8f4de2 Fixed container and listbox not accounting for contents on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
3816 size = [object getsize];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3817
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3818 thiswidth = size.width;
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3819 thisheight = size.height;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3820
1549
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3821 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3822 thiswidth = _DW_SCROLLED_MIN_WIDTH;
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3823 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3824 thiswidth = _DW_SCROLLED_MAX_WIDTH;
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3825 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3826 thisheight = _DW_SCROLLED_MIN_HEIGHT;
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3827 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3828 thisheight = _DW_SCROLLED_MAX_HEIGHT;
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
3829 }
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3830 /* Tree */
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
3831 else if([ object isMemberOfClass:[DWTree class] ])
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1533
diff changeset
3832 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1564
diff changeset
3833 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2);
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1564
diff changeset
3834 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3835 }
1533
7bc189ef0cd0 Add code to determine the size of the calendar control on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
3836 /* Any other control type */
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3837 else if([ object isKindOfClass:[ NSControl class ] ])
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3838 nsstr = [object stringValue];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3839
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3840 /* If we have a string...
1564
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
3841 * calculate the size with the current font.
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
3842 */
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
3843 if(nsstr && [nsstr length])
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
3844 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3845
1418
461240f946d0 Status text fields needs extra space on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3846 /* Handle static text fields */
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3847 if([object isKindOfClass:[ NSTextField class ]] && ![object isEditable])
1418
461240f946d0 Status text fields needs extra space on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3848 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3849 id border = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3850
1778
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
3851 extrawidth = 10;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3852
1418
461240f946d0 Status text fields needs extra space on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3853 /* Handle status bar field */
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3854 if([border isMemberOfClass:[ NSBox class ] ])
1564
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
3855 {
1778
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
3856 extrawidth += 2;
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
3857 extraheight = 8;
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
3858 }
1418
461240f946d0 Status text fields needs extra space on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3859 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3860
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
3861 /* Set the requested sizes */
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3862 if(width)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3863 *width = thiswidth + extrawidth;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3864 if(height)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3865 *height = thisheight + extraheight;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3866 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3867
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3868 /* 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
3869 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
3870 {
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
3871 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
3872 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
3873 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
3874 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
3875 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
3876 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
3877 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
3878 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
3879
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3880 /*
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3881 * 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
3882 * 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
3883 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3884 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
3885 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3886 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
3887 return;
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3888 }
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
3889
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
3890 /* 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
3891 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
3892 {
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
3893 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
3894 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
3895 }
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
3896 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
3897 {
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
3898 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
3899 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
3900 }
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
3901
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
3902 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
3903 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
3904 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
3905
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
3906 /* Query the objects */
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
3907 if([ object isMemberOfClass:[ DWContainer class ] ] ||
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
3908 [ object isMemberOfClass:[ DWTree class ] ] ||
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
3909 [ object isMemberOfClass:[ DWMLE class ] ])
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
3910 {
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
3911 this = item = [object scrollview];
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
3912 }
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
3913
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
3914 /* Do some sanity bounds checking */
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
3915 if(!thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
3916 thisbox->count = 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
3917 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
3918 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
3919 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
3920 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
3921
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
3922 /* Duplicate the existing data */
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
3923 tmpitem = calloc(sizeof(Item), (thisbox->count+1));
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
3924
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
3925 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
3926 {
1079
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3927 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
3928 x++;
5d3acda4acd4 Fixed a minor cut and paste error and formatting on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
3929 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
3930 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
3931 }
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
3932
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
3933 /* 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
3934 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
3935 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
3936 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
3937 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
3938
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
3939 /* 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
3940 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
3941 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
3942 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
3943 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3944 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
3945 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
3946 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
3947 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
3948
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
3949 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
3950 }
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
3951
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
3952 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
3953 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
3954 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
3955 tmpitem[index].pad = pad;
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3956 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3957 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
3958
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3959 /* If either of the parameters are -1 ... calculate the size */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3960 if(width == -1 || height == -1)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3961 _control_size(object, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL);
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
3962
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
3963 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
3964
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
3965 /* 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
3966 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
3967
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
3968 /* 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
3969 [view addSubview:this];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3970 /* Enable autorelease on the item...
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3971 * so it will get destroyed when the parent is.
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3972 */
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
3973 [this autorelease];
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
3974 /* 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
3975 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
3976 {
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
3977 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
3978
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
3979 /* 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
3980 * 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
3981 */
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
3982 [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
3983 }
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
3984 /* Queue a redraw on the top-level window */
1673
db393069b27d Fix packing padding not triggering automatic redraws on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1672
diff changeset
3985 _dw_redraw([view window], TRUE);
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
3986
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
3987 /* Free the old data */
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
3988 if(thisitem)
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
3989 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
3990 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
3991 }
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
3992
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
3993 /*
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
3994 * Remove windows (widgets) from the box they are packed into.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
3995 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1678
diff changeset
3996 * handle: Window handle of the packed item to be removed.
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
3997 * Returns:
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
3998 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
3999 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1764
diff changeset
4000 int API dw_box_unpack(HWND handle)
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4001 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4002 int _locked_by_me = FALSE;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4003 DW_LOCAL_POOL_IN;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4004 DW_MUTEX_LOCK;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4005 id object = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4006
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4007 if([object isKindOfClass:[NSView class]] || [object isKindOfClass:[NSControl class]])
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4008 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4009 DWBox *parent = (DWBox *)[object superview];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4010
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4011 /* Some controls are embedded in scrollviews...
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4012 * so get the parent of the scrollview in that case.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4013 */
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4014 if(([object isKindOfClass:[NSTableView class]] || [object isMemberOfClass:[DWMLE class]])
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4015 && [parent isMemberOfClass:[NSClipView class]])
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4016 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4017 object = [parent superview];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4018 parent = (DWBox *)[object superview];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4019 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4020
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4021 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]])
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4022 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4023 id window = [object window];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4024 Box *thisbox = [parent box];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4025 int z, index = -1;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4026 Item *tmpitem = NULL, *thisitem = thisbox->items;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4027
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4028 if(!thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4029 thisbox->count = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4030
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4031 for(z=0;z<thisbox->count;z++)
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4032 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4033 if(thisitem[z].hwnd == object)
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4034 index = z;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4035 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4036
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4037 if(index == -1)
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4038 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4039 DW_MUTEX_UNLOCK;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4040 DW_LOCAL_POOL_OUT;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4041 return DW_ERROR_GENERAL;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4042 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4043
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4044 [object retain];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4045 [object removeFromSuperview];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4046
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4047 if(thisbox->count > 1)
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4048 {
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4049 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4050
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4051 /* Copy all but the current entry to the new list */
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4052 for(z=0;z<index;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4053 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4054 tmpitem[z] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4055 }
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4056 for(z=index+1;z<thisbox->count;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4057 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4058 tmpitem[z-1] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4059 }
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4060 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4061
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4062 thisbox->items = tmpitem;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4063 if(thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4064 free(thisitem);
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4065 if(tmpitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4066 thisbox->count--;
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4067 else
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4068 thisbox->count = 0;
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4069 /* Queue a redraw on the top-level window */
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4070 _dw_redraw(window, TRUE);
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4071 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4072 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4073 DW_MUTEX_UNLOCK;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4074 DW_LOCAL_POOL_OUT;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4075 return DW_ERROR_NONE;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4076 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4077
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4078 /*
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4079 * Remove windows (widgets) from a box at an arbitrary location.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4080 * Parameters:
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4081 * box: Window handle of the box to be removed from.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4082 * index: 0 based index of packed items.
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4083 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1678
diff changeset
4084 * Handle to the removed item on success, 0 on failure or padding.
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4085 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1764
diff changeset
4086 HWND API dw_box_unpack_at_index(HWND box, int index)
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4087 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4088 int _locked_by_me = FALSE;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4089 DW_LOCAL_POOL_IN;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4090 DW_MUTEX_LOCK;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4091 DWBox *parent = (DWBox *)box;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4092 id object = nil;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4093
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4094 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]])
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4095 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4096 id window = [parent window];
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4097 Box *thisbox = [parent box];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4098
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4099 if(thisbox && index > -1 && index < thisbox->count)
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4100 {
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4101 int z;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4102 Item *tmpitem = NULL, *thisitem = thisbox->items;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4103
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4104 object = thisitem[index].hwnd;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4105
1672
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4106 if(object)
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4107 {
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4108 [object retain];
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4109 [object removeFromSuperview];
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4110 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4111
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4112 if(thisbox->count > 1)
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4113 {
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4114 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4115
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4116 /* Copy all but the current entry to the new list */
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4117 for(z=0;thisitem && z<index;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4118 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4119 tmpitem[z] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4120 }
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4121 for(z=index+1;z<thisbox->count;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4122 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4123 tmpitem[z-1] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4124 }
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4125 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4126
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4127 thisbox->items = tmpitem;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4128 if(thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4129 free(thisitem);
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4130 if(tmpitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4131 thisbox->count--;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4132 else
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
4133 thisbox->count = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
4134
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4135 /* Queue a redraw on the top-level window */
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4136 _dw_redraw(window, TRUE);
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4137 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4138 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4139 DW_MUTEX_UNLOCK;
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4140 DW_LOCAL_POOL_OUT;
1672
42890a2b8d3e Fix minor issues with dw_box_remove_at_index() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1671
diff changeset
4141 return object;
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4142 }
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4143
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
4144 /*
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4145 * 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
4146 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
4148 * item: Window handle of the item to pack.
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
4149 * 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
4150 * 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
4151 * 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
4152 * 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
4153 * 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
4154 * 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
4155 */
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4156 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
4157 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4158 _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
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 * 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
4163 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
4165 * item: Window handle of the item to pack.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 * 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
4167 * 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
4168 * 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
4169 * 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
4170 * 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
4171 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 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
4173 {
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
4174 /* 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
4175 * 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
4176 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4177 _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
4178 }
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4179
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4180 /*
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4181 * 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
4182 * Parameters:
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4183 * box: Window handle of the box to be packed into.
1678
896f377a47c7 Added exports for building with MinGW on Windows and Watcom on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
4184 * item: Window handle of the item to pack.
1086
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4185 * 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
4186 * 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
4187 * 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
4188 * 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
4189 * 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
4190 */
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4191 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
4192 {
4254c9b6d50d Merge all 3 box packing functions into one internal function on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1079
diff changeset
4193 _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
4194 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4196 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
4197 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4198 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
4199 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
4200 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4201 [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
4202 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4203 [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
4204 [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
4205 [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
4206 [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
4207 [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
4208 /* 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
4209 [[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
4210 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
4211 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
4212 [[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
4213 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4214 return button;
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4215 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4216
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 * 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
4219 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 * 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
4221 * 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
4222 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4223 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
4224 {
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4225 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
4226 [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
4227 [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
4228 [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
4229 [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
4230 [[button cell] setControlTint:NSBlueControlTint];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4231 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 }
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 * 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
4236 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 * 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
4238 * 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
4239 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4240 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
4241 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4242 DWEntryField *entry = [[DWEntryField alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4243 [entry setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4244 [entry setTag:cid];
1712
daa59fc8d6e5 Disable wrapping on entryfields and static text on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4245 [[entry cell] setScrollable:YES];
daa59fc8d6e5 Disable wrapping on entryfields and static text on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4246 [[entry cell] setWraps:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4247 return entry;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 * 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
4252 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 * 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
4254 * 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
4255 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4256 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
4257 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4258 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4259 [entry setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4260 [entry setTag:cid];
1712
daa59fc8d6e5 Disable wrapping on entryfields and static text on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4261 [[entry cell] setScrollable:YES];
daa59fc8d6e5 Disable wrapping on entryfields and static text on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
4262 [[entry cell] setWraps:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4263 return entry;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 * Sets the entryfield character limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 * 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
4270 * 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
4271 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4272 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
4273 {
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
4274 DWEntryField *entry = handle;
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
4275 DWEntryFieldFormatter *formatter = [[[DWEntryFieldFormatter alloc] init] autorelease];
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4276
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
4277 [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
4278 [[entry cell] setFormatter:formatter];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 * 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
4283 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 * 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
4285 * 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
4286 */
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4287 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
4288 {
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4289 NSBundle *bundle = [NSBundle mainBundle];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4290 NSString *respath = [bundle resourcePath];
1770
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
4291 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4292 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4293 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
4294 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
4295 {
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
4296 [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
4297 }
1396
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4298 if(text)
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4299 [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
4300 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4301 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * 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
4306 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 * 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
4308 * 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
4309 * 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
4310 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 * (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
4312 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4313 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
4314 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4315 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
4316
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
4317 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
4318 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
4319
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4320 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
4321 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
4322 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
4323 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
4324 }
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4325 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
4326 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
4327 {
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
4328 [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
4329 }
1396
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4330 if(text)
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4331 [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
4332 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4333 return button;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 * 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
4338 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 * 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
4340 * 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
4341 * data: The contents of the image
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 * (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
4343 * len: length of str
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4345 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
4346 {
760
2fb17622a455 Possible fix for exception in dw_bitmapbutton_new_from_data()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 755
diff changeset
4347 NSData *thisdata = [NSData dataWithBytes:data length:len];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4348 NSImage *image = [[NSImage alloc] initWithData:thisdata];
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4349 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
4350 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
4351 {
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
4352 [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
4353 }
1396
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4354 if(text)
117cc38a3799 Allow on Mac passing NULL as bubbletext to dw_bitmapbutton_new*.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
4355 [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
4356 [image release];
749
9e147366147b Code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 748
diff changeset
4357 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 * 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
4362 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 * 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
4364 * 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
4365 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4366 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
4367 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
4368 DWSpinButton *spinbutton = [[DWSpinButton alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4369 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
4370 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
4371 [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
4372 [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
4373 [stepper setMinValue:-65536];
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
4374 [stepper setMaxValue:65536];
8188f818eb9f Changed initial spinbutton limits to -65536 to 65536 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1018
diff changeset
4375 [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
4376 [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
4377 return spinbutton;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 * Sets the spinbutton value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383 * 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
4384 * position: Current value of the spinbutton.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 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
4387 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
4388 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4389 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
4390 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
4391 [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
4392 [textfield takeIntValueFrom:stepper];
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 * Sets the spinbutton limits.
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 * 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
4399 * upper: Upper limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400 * lower: Lower limit.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 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
4403 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
4404 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4405 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
4406 [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
4407 [stepper setMaxValue:(double)upper];
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 * 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
4412 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 * handle: Handle to the spinbutton to be queried.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 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
4416 {
678
0ec8edbb82cf Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 677
diff changeset
4417 DWSpinButton *spinbutton = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4418 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
4419 return (long)[stepper integerValue];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 * 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
4424 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 * 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
4426 * 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
4427 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4428 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
4429 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4430 DWButton *button = _button_new(text, cid);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4431 [button setButtonType:NSRadioButton];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4432 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 * 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
4437 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 * 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
4439 * increments: Number of increments available.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 * 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
4441 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4442 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
4443 {
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4444 DWSlider *slider = [[DWSlider alloc] init];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4445 [slider setMaxValue:(double)increments];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4446 [slider setMinValue:0];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4447 [slider setContinuous:YES];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4448 [slider setTarget:slider];
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4449 [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
4450 [slider setTag:cid];
704
336800e9e648 Fixes to the slider control so events happen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 703
diff changeset
4451 return slider;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 * Returns the position of the slider.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 * 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
4458 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 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
4460 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4461 DWSlider *slider = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4462 double val = [slider doubleValue];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4463 return (int)val;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 * Sets the slider position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 * handle: Handle to the slider to be set.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 * 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
4471 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 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
4473 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4474 DWSlider *slider = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4475 [slider setDoubleValue:(double)position];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476 }
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 * 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
4480 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 * 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
4482 * increments: Number of increments available.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 * 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
4484 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4485 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
4486 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4487 DWScrollbar *scrollbar;
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4488 if(vertical)
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4489 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4490 scrollbar = [[DWScrollbar alloc] init];
1419
8827e9b14b40 Initial support for automatic window redrawing on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1418
diff changeset
4491 [scrollbar setVertical:YES];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4492 }
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4493 else
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4494 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4495 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
4496 }
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4497 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4498 [scrollbar setTarget:scrollbar];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4499 [scrollbar setAction:@selector(changed:)];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4500 [scrollbar setRange:0.0 andVisible:0.0];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4501 [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
4502 [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
4503 [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
4504 [scrollbar setTag:cid];
689
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4505 [scrollbar setEnabled:YES];
4199730e9889 Fixed errors creating scrollbars.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 688
diff changeset
4506 return scrollbar;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 * Returns the position of the scrollbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512 * handle: Handle to the scrollbar to be queried.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 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
4515 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4516 DWScrollbar *scrollbar = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4517 float range = [scrollbar range];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4518 float fresult = [scrollbar doubleValue] * range;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4519 return (int)fresult;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 * Sets the scrollbar position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 * 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
4526 * 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
4527 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 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
4529 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4530 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
4531 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
4532 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
4533 double newpos = (double)position/(range-visible);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4534 [scrollbar setDoubleValue:newpos];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 * Sets the scrollbar range.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 * 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
4541 * range: Maximum range value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542 * 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
4543 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 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
4545 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4546 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
4547 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
4548 [scrollbar setRange:(double)range andVisible:(double)visible];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4549 [scrollbar setKnobProportion:knob];
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 * 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
4554 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 * 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
4556 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4557 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
4558 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4559 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
4560 [percent setStyle:NSProgressIndicatorBarStyle];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4561 [percent setBezeled:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4562 [percent setMaxValue:100];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4563 [percent setMinValue:0];
714
cf6246f86c04 Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 713
diff changeset
4564 [percent incrementBy:1];
cf6246f86c04 Fixed the percent/progress indicators from always being indeterminate.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 713
diff changeset
4565 [percent setIndeterminate:NO];
1586
021d2966f84d Make sure the percent widget defaults to 0% on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1582
diff changeset
4566 [percent setDoubleValue:0];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4567 /*[percent setTag:cid]; Why doesn't this work? */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4568 return percent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 * Sets the percent bar position.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 * 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
4575 * 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
4576 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 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
4578 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4579 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
4580
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
4581 /* 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
4582 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
4583 {
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
4584 [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
4585 [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
4586 }
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
4587 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
4588 {
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
4589 /* 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
4590 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
4591 {
698875cfe8e5 Fixed the indeterminate percent bar should be animated on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
4592 [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
4593 [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
4594 }
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
4595 [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
4596 }
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 * 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
4601 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 * 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
4603 * 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
4604 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4605 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
4606 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4607 DWButton *button = _button_new(text, cid);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4608 [button setButtonType:NSSwitchButton];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4609 [button setBezelStyle:NSRegularSquareBezelStyle];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4610 return button;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 * Returns the state of the checkbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 * 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
4617 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 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
4619 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4620 DWButton *button = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4621 if([button state])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4622 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4623 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4624 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4625 return FALSE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 * Sets the state of the checkbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 * 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
4632 * 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
4633 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 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
4635 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4636 DWButton *button = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4637 if(value)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4638 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4639 [button setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4640 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4641 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4642 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4643 [button setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4644 }
656
6c8b95ca877b Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 655
diff changeset
4645
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647
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
4648 /* 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
4649 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
4650 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4651 NSScrollView *scrollview = [[NSScrollView alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4652 DWContainer *cont = [[DWContainer alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4653
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
4654 [cont setScrollview:scrollview];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
4655 [scrollview setBorderType:NSBezelBorder];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
4656 [scrollview setHasVerticalScroller:YES];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
4657 [scrollview setAutohidesScrollers:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4658
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4659 if(multi)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4660 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4661 [cont setAllowsMultipleSelection:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4662 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4663 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4664 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4665 [cont setAllowsMultipleSelection:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4666 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4667 [cont setDataSource:cont];
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
4668 [cont setDelegate:cont];
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
4669 [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
4670 [cont setTag:cid];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
4671 [cont autorelease];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4672 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
4673 }
0502e5b6743b Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 657
diff changeset
4674
650
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 * 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
4677 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 * 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
4679 * multi: Multiple select TRUE or FALSE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
4681 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
4682 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4683 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4684 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4685 DWContainer *cont = _cont_new(cid, multi);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4686 [cont setHeaderView:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4687 int type = DW_CFA_STRING;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4688 [cont setup];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
4689 NSTableColumn *column = [[[NSTableColumn alloc] init] autorelease];
795
f23cad02cfb3 Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 794
diff changeset
4690 [column setEditable:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4691 [cont addTableColumn:column];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4692 [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
4693 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4694 return cont;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 * 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
4699 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 * 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
4701 * text: Text to append into listbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 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
4704 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4705 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4706 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4707 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4708
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4709 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4710 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4711 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4712
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4713 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4714 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4715 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
4716 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4717 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
4718 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
4719 NSArray *newrow = [NSArray arrayWithObject:nstr];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4720
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4721 [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
4722 /*[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
4723 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
4724 waitUntilDone:YES];*/
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4725 [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
4726 [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
4727 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4728 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 * 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
4733 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 * handle: Handle to the listbox to be inserted into.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 * text: Text to insert into listbox.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 * 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
4737 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 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
4739 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4740 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4741 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4742 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4743
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4744 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4745 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4746 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4747
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4748 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4749 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4750 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
4751 {
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4752 DWContainer *cont = handle;
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4753 NSString *nstr = [ NSString stringWithUTF8String:text ];
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4754 NSArray *newrow = [NSArray arrayWithObject:nstr];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4755
687
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4756 [cont insertRow:newrow at:pos];
5dde8d34bc69 Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 686
diff changeset
4757 [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
4758 [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
4759 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4760 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 * 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
4765 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * 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
4767 * 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
4768 * 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
4769 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 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
4771 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4772 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4773 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4774 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4775
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4776 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4777 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4778 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4779 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4780
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4781 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
4782 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4783 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4784 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4785 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4786 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
4787 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4788 DWContainer *cont = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4789 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4790
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4791 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
4792 {
1318
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4793 NSString *nstr = [NSString stringWithUTF8String:text[z]];
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
4794 NSArray *newrow = [NSArray arrayWithObjects:nstr,nil];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4795
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4796 [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
4797 }
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4798 [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
4799 [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
4800 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4801 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803
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 * 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
4806 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807 * 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
4808 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 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
4810 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4811 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4812 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4813 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4814
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4815 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4816 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4817 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4818
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4819 [combo removeAllItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4820 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4821 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
4822 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4823 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4824
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4825 [cont clear];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
4826 [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
4827 [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
4828 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4829 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 * Returns the listbox's item count.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 * 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
4836 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 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
4838 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4839 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4840
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4841 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4842 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4843 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4844
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4845 return (int)[combo numberOfItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4846 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4847 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
4848 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4849 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4850 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
4851 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
4852 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
4853 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
4854 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
4855 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4856 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 * 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
4861 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 * 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
4863 * top: Index to the top item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 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
4866 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4867 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4868 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4869 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4870
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4871 if([object isMemberOfClass:[DWComboBox class]])
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 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4874
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4875 [combo scrollItemAtIndexToTop:top];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4876 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4877 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
4878 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4879 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4880
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4881 [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
4882 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4883 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 * 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
4888 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 * 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
4890 * 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
4891 * 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
4892 * 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
4893 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 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
4895 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4896 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4897 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4898 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4899
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4900 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4901 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4902 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
4903 int count = (int)[combo numberOfItems];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4904
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
4905 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
4906 {
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
4907 *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
4908 }
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
4909 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
4910 {
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
4911 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
4912 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
4913 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4914 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4915 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
4916 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4917 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
4918 int count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4919
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
4920 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
4921 {
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
4922 *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
4923 }
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
4924 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
4925 {
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
4926 NSString *nstr = [cont getRow:index and:0];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4927
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
4928 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
4929 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4930 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4931 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 * 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
4936 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 * 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
4938 * 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
4939 * 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
4940 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 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
4942 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4943 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4944 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4945 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4946
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4947 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4948 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4949 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
4950 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
4951
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
4952 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
4953 {
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
4954 [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
4955 [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
4956 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4957 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4958 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
4959 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4960 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
4961 int count = (int)[cont numberOfRowsInTableView:cont];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4962
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
4963 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
4964 {
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
4965 NSString *nstr = [ NSString stringWithUTF8String:buffer ];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4966
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
4967 [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
4968 [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
4969 [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
4970 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4971 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
4972 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 * 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
4977 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 * 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
4979 */
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
4980 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
4981 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4982 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
4983
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4984 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4985 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4986 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4987 return (int)[combo indexOfSelectedItem];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4988 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
4989 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
4990 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4991 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
4992 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
4993 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
4994 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
4995 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
4996 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
4997 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
4998 return -1;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 * 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
5003 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 * 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
5005 * 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
5006 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 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
5008 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5009 int _locked_by_me = FALSE;
578bbfd8c904 Added 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_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5011 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
5012 int retval = -1;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5013
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5014 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
5015 {
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
5016 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
5017 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
5018 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
5019 if( where == -1 )
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
5020 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
5021 else
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
5022 result = [selected indexGreaterThanIndex:where];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5023
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5024 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
5025 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5026 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
5027 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5028 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5029 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5030 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 * 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
5035 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 * 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
5037 * index: Item index.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 * 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
5039 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040 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
5041 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5042 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5043 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5044 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5045
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5046 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5047 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5048 DWComboBox *combo = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5049 if(state)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5050 [combo selectItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5051 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5052 [combo deselectItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5053 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5054 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
5055 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5056 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
5057 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5058
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5059 [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
5060 [selected release];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5061 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5062 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 * 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
5067 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 * 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
5069 * index: Item index.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 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
5072 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5073 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5074 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5075 id object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5076
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5077 if([object isMemberOfClass:[DWComboBox class]])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5078 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5079 DWComboBox *combo = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5080
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5081 [combo removeItemAtIndex:index];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5082 }
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5083 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
5084 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5085 DWContainer *cont = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5086
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
5087 [cont removeRow:index];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
5088 [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
5089 [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
5090 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5091 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 * 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
5096 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 * 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
5098 * 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
5099 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5100 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
5101 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5102 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
5103 [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
5104 [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
5105 [combo setTag:cid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5106 return combo;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 * 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
5111 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * 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
5113 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5114 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
5115 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5116 DWMLE *mle = [[DWMLE alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5117 NSScrollView *scrollview = [[NSScrollView alloc] init];
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5118 NSSize size = [mle maxSize];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5119
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5120 size.width = size.height;
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5121 [mle setMaxSize: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
5122 [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
5123 [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
5124 [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
5125 [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
5126 [scrollview setDocumentView:mle];
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5127 [mle setVerticallyResizable:YES];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5128 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5129 [mle setScrollview:scrollview];
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5130 /* [mle setTag:cid]; Why doesn't this work? */
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
5131 [mle autorelease];
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5132 return mle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5133 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 * 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
5137 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 * 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
5139 * buffer: Text buffer to be imported.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 * startpoint: Point to start entering text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 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
5143 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5144 DWMLE *mle = 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
5145 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
5146 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
5147 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
5148 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
5149 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
5150 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
5151 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
5152 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
5153 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
5154 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
5155 [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
5156 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5157 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
5158 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 * Grabs text from an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 * 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
5164 * buffer: Text buffer to be exported.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 * startpoint: Point to start grabbing text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 * 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
5167 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 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
5169 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5170 DWMLE *mle = 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
5171 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
5172 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
5173 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
5174 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
5175 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
5176 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
5177 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
5178 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5182 * Obtains information about an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 * 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
5185 * 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
5186 * 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
5187 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 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
5189 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5190 DWMLE *mle = 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
5191 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
5192 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
5193 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
5194 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
5195 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
5196
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
5197 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
5198 *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
5199 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
5200 {
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
5201 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
5202 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
5203
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
5204 *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
5205 }
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
5206 DW_MUTEX_LOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 * Deletes text from an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 * handle: 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
5213 * startpoint: Point to start deleting text.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 * 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
5215 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 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
5217 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5218 DWMLE *mle = 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
5219 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
5220 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
5221 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
5222 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
5223 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
5224 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
5225 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
5226 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
5227 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
5228 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
5229 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
5230 [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
5231 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 * 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
5236 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 * 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
5238 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 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
5240 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5241 DWMLE *mle = 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
5242 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
5243 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
5244 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
5245 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
5246 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
5247 [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
5248 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 * 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
5253 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 * 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
5255 * line: Line to be visible.
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 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
5258 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5259 DWMLE *mle = 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
5260 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
5261 DW_MUTEX_LOCK;
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5262 NSTextStorage *ts = [mle textStorage];
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5263 NSMutableString *ms = [ts mutableString];
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5264 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
5265
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5266 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
5267 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
5268
802
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5269 if(line == numberOfLines)
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5270 {
676d46b31a11 Initial implementation of dw_mle_set_visible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 801
diff changeset
5271 [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
5272 }
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
5273 DW_MUTEX_UNLOCK;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 * 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
5278 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 * handle: Handle to the MLE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 * 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
5281 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 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
5283 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5284 DWMLE *mle = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5285 if(state)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5286 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5287 [mle setEditable:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5288 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5289 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5290 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5291 [mle setEditable:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5292 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 * 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
5297 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 * handle: Handle to the MLE.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 * 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
5300 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 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
5302 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5303 DWMLE *mle = handle;
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5304 NSScrollView *sv = [mle scrollview];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5305
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
5306 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
5307 {
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5308 [[mle textContainer] setWidthTracksTextView:YES];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5309 [sv setHasHorizontalScroller:NO];
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
5310 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
5311 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
5312 {
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5313 [[mle textContainer] setWidthTracksTextView:NO];
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5314 [[mle textContainer] setContainerSize:[mle maxSize]];
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
5315 [mle setHorizontallyResizable:YES];
1551
cf897886ceeb Fixed disabling word wrap in the MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1549
diff changeset
5316 [sv setHasHorizontalScroller:YES];
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
5317 }
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 * 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
5322 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 * 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
5324 * point: Point to position cursor.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 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
5327 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5328 DWMLE *mle = 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
5329 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
5330 DW_MUTEX_LOCK;
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
5331 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
5332 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
5333 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
5334 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
5335 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
5336 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
5337 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
5338 [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
5339 [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
5340 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 * Finds text in an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 * handle: 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
5347 * text: Text to search for.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 * point: Start point of search.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 * flags: Search specific flags.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 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
5352 {
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
5353 DWMLE *mle = 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
5354 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
5355 DW_MUTEX_LOCK;
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5356 NSTextStorage *ts = [mle textStorage];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5357 NSMutableString *ms = [ts mutableString];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5358 NSString *searchForMe = [NSString stringWithUTF8String:text];
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5359 NSRange searchRange = NSMakeRange(point, [ms length] - point);
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5360 NSRange range = NSMakeRange(NSNotFound, 0);
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5361 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
5362
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5363 if(ms)
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5364 {
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5365 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
5366 }
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
5367 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
5368 if(range.location != NSNotFound)
888
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5369 {
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5370 return -1;
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5371 }
cd6ff038e38b Implemented dw_mle_search on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 887
diff changeset
5372 return (int)range.location;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 * Stops redrawing of an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 * 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
5379 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 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
5381 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5382 /* 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
5383 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * Resumes redrawing of an MLE box.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 * 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
5389 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 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
5391 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5392 /* 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
5393 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 * 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
5397 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 * 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
5399 * 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
5400 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5401 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
5402 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5403 NSBox *border = [[NSBox alloc] init];
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
5404 NSTextField *textfield = dw_text_new(text, cid);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5405
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5406 [border setBorderType:NSGrooveBorder];
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5407 //[border setBorderType:NSLineBorder];
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5408 [border setTitlePosition:NSNoTitle];
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5409 [border setContentView:textfield];
1778
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
5410 [border setContentViewMargins:NSMakeSize(1.5,1.5)];
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5411 [textfield autorelease];
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
5412 [textfield setBackgroundColor:[NSColor clearColor]];
931
dfd84cefd80b Minor changes to vertical centering on (status) text fields on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 930
diff changeset
5413 [[textfield cell] setVCenter:YES];
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
5414 return border;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 * 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
5419 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 * 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
5421 * 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
5422 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5423 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
5424 {
1564
d84a690448c3 Attempted fix at border calculation on Mac for status text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1559
diff changeset
5425 DWText *textfield = [[DWText 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
5426 [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
5427 [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
5428 [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
5429 [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
5430 [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
5431 [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
5432 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
5433 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
5434 [[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
5435 }
1712
daa59fc8d6e5 Disable wrapping on entryfields and static text on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1709
diff changeset
5436 [[textfield cell] setWraps:NO];
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
5437 return textfield;
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 * 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
5442 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 * 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
5444 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 * 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
5446 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5447 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
5448 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5449 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
5450 [render setTag:cid];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5451 return render;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 /* Sets the current foreground drawing color.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 * red: red value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * green: green value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 * blue: blue value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 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
5461 {
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
5462 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
5463 NSColor *newcolor;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5464 DW_LOCAL_POOL_IN;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5465
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5466 _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
5467
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5468 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
5469 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
5470 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
5471 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
5472 [oldcolor release];
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5473 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 /* Sets the current background drawing color.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 * red: red value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 * green: green value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 * blue: blue value.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 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
5483 {
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
5484 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
5485 NSColor *newcolor;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5486 DW_LOCAL_POOL_IN;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5487
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
5488 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
5489 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5490 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
5491 }
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5492 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
5493 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5494 _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
5495
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
5496 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
5497 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
5498 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
5499 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
5500 }
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
5501 [oldcolor release];
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5502 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 /* 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
5506 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 * value: current color
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 * 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
5510 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 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
5512 {
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
5513 /* Create the Color Chooser Dialog class. */
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5514 DWColorChoose *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
5515 DWDialog *dialog;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
5516 DW_LOCAL_POOL_IN;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5517
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5518 if(![DWColorChoose sharedColorPanelExists])
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
5519 {
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
5520 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
5521 /* 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
5522 [colorDlg setContinuous:NO];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5523 [colorDlg setTarget:colorDlg];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5524 [colorDlg setAction:@selector(changeColor:)];
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5525 }
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5526 else
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5527 colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5528
1644
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5529 /* If someone is already waiting just return */
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5530 if([colorDlg dialog])
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5531 {
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5532 DW_LOCAL_POOL_OUT;
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5533 return value;
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5534 }
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5535
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5536 unsigned long tempcol = _get_color(value);
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5537 NSColor *color = [[NSColor colorWithDeviceRed: DW_RED_VALUE(tempcol)/255.0 green: DW_GREEN_VALUE(tempcol)/255.0 blue: DW_BLUE_VALUE(tempcol)/255.0 alpha: 1] retain];
2b55465887e1 Color chooser changes for Lion compatibility on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1610
diff changeset
5538 [colorDlg setColor:color];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5539
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
5540 dialog = dw_dialog_new(colorDlg);
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
5541 [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
5542 [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
5543
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
5544 /* 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
5545 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
5546
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
5547 /* 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
5548 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
5549 [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
5550 value = DW_RGB((int)(red * 255), (int)(green *255), (int)(blue *255));
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
5551 DW_LOCAL_POOL_OUT;
732
db3a173e487e Fixes for the color chooser... it now works a single time. However...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 731
diff changeset
5552 return value;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 /* 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
5556 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 * 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
5559 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 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
5563 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5564 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5565 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added 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_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5567 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5568 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5569 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5570 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
5571 [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
5572 [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
5573 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5574 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5575 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5576 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5577 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
5578 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5579 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5580 DW_LOCAL_POOL_OUT;
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
5581 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
5582 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5583 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5584 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5585 NSBezierPath* aPath = [NSBezierPath bezierPath];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5586 [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
5587 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
5588 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5589
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5590 [aPath moveToPoint:NSMakePoint(x, y)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5591 [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
5592 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
5593 {
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
5594 [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
5595 }
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
5596 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
5597 {
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
5598 [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
5599 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5600 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5601 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 /* 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
5605 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 * 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
5608 * x1: First X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 * y1: First Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 * x2: Second X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 * y2: Second Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 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
5614 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5615 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5616 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5617 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5618 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5619 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5620 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5621 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
5622 [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
5623 [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
5624 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5625 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5626 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5627 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5628 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
5629 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5630 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5631 DW_LOCAL_POOL_OUT;
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
5632 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
5633 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5634 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5635 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5636 NSBezierPath* aPath = [NSBezierPath bezierPath];
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
5637 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
5638 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5639
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5640 [aPath moveToPoint:NSMakePoint(x1 + 0.5, y1 + 0.5)];
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5641 [aPath lineToPoint:NSMakePoint(x2 + 0.5, y2 + 0.5)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5642 [aPath stroke];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5643
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
5644 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
5645 {
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
5646 [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
5647 }
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
5648 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
5649 {
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
5650 [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
5651 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5652 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5653 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656 /* 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
5657 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 * 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
5660 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 * text: Text to be displayed.
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 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
5665 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5666 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5667 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5668 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
5669 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
5670 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
5671 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
5672 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5673 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
5674 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5675 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
5676 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
5677 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
5678 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5679 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5680 DW_LOCAL_POOL_OUT;
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
5681 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
5682 }
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
5683 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
5684 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
5685 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
5686 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
5687 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5688 [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
5689 }
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
5690 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
5691 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5692 [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
5693 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5694 [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
5695 [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
5696 [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
5697 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5698 _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
5699 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5700 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
5701 {
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
5702 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
5703 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
5704 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
5705 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5706 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
5707 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5708 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
5709 [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
5710 [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
5711 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
5712 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
5713 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
5714 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
5715 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
5716 {
3774af45eb0c Fix for dw_draw_text() not using the background color on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 890
diff changeset
5717 [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
5718 }
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
5719 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
5720 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5721 [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
5722 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5723 [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
5724 [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
5725 [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
5726 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5727 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5728 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 /* 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
5732 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 * 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
5735 * text: Text to be queried.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * 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
5737 * 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
5738 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 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
5740 {
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
5741 id object = handle;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5742 NSString *nstr;
1230
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5743 NSFont *font = nil;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5744 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5745
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5746 nstr = [NSString stringWithUTF8String:text];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5747
1230
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5748 /* Check the pixmap for associated object or 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
5749 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
5750 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5751 object = pixmap->handle;
1230
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5752 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
5753 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5754 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
1230
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5755 /* If we didn't get a font from the pixmap... try the associated object */
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5756 if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]]))
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5757 {
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5758 font = [object font];
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5759 }
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5760 /* If we got a font... add it to the dictionary */
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5761 if(font)
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5762 {
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5763 [dict setValue:font forKey:NSFontAttributeName];
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5764 }
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5765 /* Calculate the size of the string */
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
5766 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
5767 [dict release];
1230
75a773cdb626 Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1225
diff changeset
5768 /* Return whatever information we can */
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
5769 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
5770 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5771 *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
5772 }
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5773 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
5774 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
5775 *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
5776 }
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5777 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5780 /* Internal function to create an image graphics context...
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5781 * with or without antialiasing enabled.
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5782 */
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5783 id _create_gc(id image, bool antialiased)
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5784 {
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5785 CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort];
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5786 NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5787 [gc setShouldAntialias:antialiased];
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5788 CGContextSetAllowsAntialiasing(context, antialiased);
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5789 return gc;
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5790 }
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5791
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 /* 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
5793 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5796 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 * width: Width of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 * height: Height of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 */
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5802 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y )
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5804 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5805 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5806 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5807 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5808 int z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5809 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5810 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5811 image = (id)pixmap->image;
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5812 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : 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
5813 [NSGraphicsContext saveGraphicsState];
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5814 [NSGraphicsContext setCurrentContext:gc];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5815 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5816 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5817 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5818 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
5819 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5820 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5821 DW_LOCAL_POOL_OUT;
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
5822 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
5823 }
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5824 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5825 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5826 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5827 NSBezierPath* aPath = [NSBezierPath bezierPath];
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
5828 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
5829 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5830
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5831 [aPath moveToPoint:NSMakePoint(*x + 0.5, *y + 0.5)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5832 for(z=1;z<npoints;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5833 {
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5834 [aPath lineToPoint:NSMakePoint(x[z] + 0.5, y[z] + 0.5)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5835 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5836 [aPath closePath];
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5837 if(flags & DW_DRAW_FILL)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5838 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5839 [aPath fill];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5840 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5841 [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
5842 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
5843 {
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
5844 [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
5845 }
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
5846 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
5847 {
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
5848 [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
5849 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5850 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5851 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 /* 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
5855 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5858 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 * width: Width of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 * height: Height of rectangle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 */
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5864 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5866 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5867 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added 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 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5869 id image = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5870 if(pixmap)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5871 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5872 image = (id)pixmap->image;
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5873 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : 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
5874 [NSGraphicsContext saveGraphicsState];
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5875 [NSGraphicsContext setCurrentContext:gc];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5876 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5877 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5878 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5879 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
5880 {
a4f99795ff26 Abort drawing functions if we fail to lock focus on a render control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 745
diff changeset
5881 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5882 DW_LOCAL_POOL_OUT;
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
5883 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
5884 }
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5885 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5886 _DWLastDrawable = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
5887 }
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
5888 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
5889 [color set];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
5890
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5891 if(flags & DW_DRAW_FILL)
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5892 [NSBezierPath fillRect:NSMakeRect(x, y, width, height)];
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5893 else
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5894 [NSBezierPath strokeRect:NSMakeRect(x, y, width, height)];
909
c092eab43ae3 Experimental change to pixmap rendering. Switch from using NSImage to NSBitmapImageRef to store the image.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 902
diff changeset
5895 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
5896 {
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
5897 [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
5898 }
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
5899 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
5900 {
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
5901 [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
5902 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5903 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5904 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5907 /* Draw an arc on a window (preferably a render window).
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5908 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5909 * handle: Handle to the window.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5910 * pixmap: Handle to the pixmap. (choose only one of these)
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5911 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5912 * DW_DRAW_FULL will draw a complete circle/elipse.
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5913 * xorigin: X coordinate of center of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5914 * yorigin: Y coordinate of center of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5915 * x1: X coordinate of first segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5916 * y1: Y coordinate of first segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5917 * x2: X coordinate of second segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5918 * y2: Y coordinate of second segment of arc.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5919 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5920 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5921 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5922 int _locked_by_me = FALSE;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5923 DW_LOCAL_POOL_IN;
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5924 DW_MUTEX_LOCK;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5925 id image = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5926
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5927 if(pixmap)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5928 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5929 image = (id)pixmap->image;
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5930 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES);
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5931 [NSGraphicsContext saveGraphicsState];
1523
026c0b4d6ee9 Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1522
diff changeset
5932 [NSGraphicsContext setCurrentContext:gc];
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5933 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5934 else
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5935 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5936 if([image lockFocusIfCanDraw] == NO)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5937 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5938 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5939 DW_LOCAL_POOL_OUT;
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5940 return;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5941 }
1527
9bab702bd6c1 A bunch of Mac drawing updates to correct issues and improve performance.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1523
diff changeset
5942 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5943 _DWLastDrawable = handle;
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5944 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5945 NSBezierPath* aPath = [NSBezierPath bezierPath];
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5946 NSColor *color = pthread_getspecific(_dw_fg_color_key);
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5947 [color set];
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5948
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1269
diff changeset
5949 /* Special case of a full circle/oval */
1269
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5950 if(flags & DW_DRAW_FULL)
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5951 {
1279
ee9a233f1b42 Fixed DW_DRAW_FULL for arcs on Mac. Rectangle was being created incorrectly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1277
diff changeset
5952 [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2 - x1, y2 - y1)];
1269
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5953 }
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5954 else
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5955 {
1650
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5956 double a1 = atan2((y1-yorigin), (x1-xorigin));
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5957 double a2 = atan2((y2-yorigin), (x2-xorigin));
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5958 double dx = xorigin - x1;
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5959 double dy = yorigin - y1;
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5960 double r = sqrt(dx*dx + dy*dy);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5961
1650
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5962 /* Convert to degrees */
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5963 a1 *= (180.0 / M_PI);
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5964 a2 *= (180.0 / M_PI);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
5965
1269
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5966 /* Prepare to draw */
1650
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5967 [aPath appendBezierPathWithArcWithCenter:NSMakePoint(xorigin, yorigin)
1f35129e4817 Improved arc drawing on the Mac using the same method as GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1649
diff changeset
5968 radius:r startAngle:a1 endAngle:a2];
1269
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5969 }
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5970 /* If the fill flag is passed */
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5971 if(flags & DW_DRAW_FILL)
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5972 {
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5973 [aPath fill];
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5974 }
9e477efbacca Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1264
diff changeset
5975 /* Actually do the drawing */
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5976 [aPath stroke];
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5977 if(pixmap)
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5978 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5979 [NSGraphicsContext restoreGraphicsState];
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5980 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5981 else
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5982 {
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5983 [image unlockFocus];
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5984 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5985 DW_MUTEX_UNLOCK;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
5986 DW_LOCAL_POOL_OUT;
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5987 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1247
diff changeset
5988
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 * 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
5991 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 * 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
5993 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
5995 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
5996 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5997 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
5998 DW_MUTEX_LOCK;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
5999 NSScrollView *scrollview = [[NSScrollView alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6000 DWTree *tree = [[DWTree alloc] init];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6001
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
6002 [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
6003 [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
6004 [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
6005 [scrollview setAutohidesScrollers:YES];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6006
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
6007 [tree setAllowsMultipleSelection:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6008 [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
6009 [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
6010 [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
6011 [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
6012 [tree setTag:cid];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
6013 [tree autorelease];
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6014 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
6015 return tree;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 * 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
6020 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 * 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
6022 * 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
6023 * 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
6024 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 * 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
6026 * itemdata: Item specific data.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 */
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
6028 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
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;
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
6032 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
6033 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
6034 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
6035 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
6036 [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
6037 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
6038 [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
6039 [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
6040 [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
6041 [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
6042 [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
6043 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
6044 [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
6045 else
2ebaea72ac95 Fix for some release calls causing issues on MacOS 10.7 Lion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1061
diff changeset
6046 [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
6047 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6048 return treenode;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 * 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
6053 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 * 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
6055 * 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
6056 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 * 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
6058 * itemdata: Item specific data.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 */
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
6060 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
6061 {
680
db315779a283 Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 679
diff changeset
6062 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
6063 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064
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 * 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
6067 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 * 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
6069 * 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
6070 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 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
6072 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6073 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6074 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
6075 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
6076 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
6077 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
6078 return strdup([nstr UTF8String]);
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 * 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
6083 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 * 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
6085 * 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
6086 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 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
6088 {
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
6089 int _locked_by_me = FALSE;
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
6090 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
6091 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
6092
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
6093 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
6094 parent = [tree parentForItem:item];
881
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
6095 DW_MUTEX_UNLOCK;
7b2750744552 Implemented dw_tree_get_parent() for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 873
diff changeset
6096 return parent;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 * 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
6101 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * handle: Handle to the tree containing the item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 * 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
6104 * 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
6105 * icon: Handle to coresponding icon.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 */
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
6107 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
6108 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6109 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6110 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
6111 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
6112 NSMutableArray *array = (NSMutableArray *)item;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6113 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6114
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
6115 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
6116 {
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
6117 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
6118 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
6119 [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
6120 [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
6121 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
6122 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
6123 {
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
6124 [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
6125 }
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
6126 [tree reloadData];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6127 DW_LOCAL_POOL_OUT;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6128 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 * 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
6133 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 * handle: Handle to the tree containing the item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 * 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
6136 * 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
6137 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 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
6139 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6140 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6141 DW_MUTEX_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
6142 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
6143 [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
6144 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 * 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
6149 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 * handle: Handle to the tree containing the item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 * 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
6152 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 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
6154 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6155 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
6156 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
6157 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
6158 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
6159 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
6160 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
6161 {
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
6162 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
6163 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6164 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
6165 return result;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 * Sets this item as the active selection.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 * handle: Handle to the tree window (widget) to be selected.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 * 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
6173 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 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
6175 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6176 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6177 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
6178 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
6179 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
6180 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
6181 {
de4aa126fb2f Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 681
diff changeset
6182 [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
6183 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6184 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 * Removes all nodes from a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 * handle: 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
6191 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 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
6193 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6194 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6195 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
6196 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
6197 [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
6198 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202 * Expands a node on a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 * 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
6205 * 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
6206 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 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
6208 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6209 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6210 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
6211 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
6212 [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
6213 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 * Collapses a node on a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 * 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
6220 * 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
6221 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 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
6223 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6224 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6225 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
6226 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
6227 [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
6228 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 * Removes a node from a tree.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 * 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
6235 * 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
6236 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237 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
6238 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6239 int _locked_by_me = FALSE;
578bbfd8c904 Added 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_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
6241 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
6242 [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
6243 [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
6244 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246
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 * 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
6249 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 * 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
6251 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
6253 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
6254 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6255 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6256 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
6257 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
6258 NSScrollView *scrollview = [cont scrollview];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
6259 [scrollview setHasHorizontalScroller:YES];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
6260 NSTableHeaderView *header = [[[NSTableHeaderView alloc] init] autorelease];
708
5fe2ca5ef88b Fixes for container event handling. Also made container/listbox cells non-editable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 707
diff changeset
6261 [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
6262 [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
6263 [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
6264 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
6265 return cont;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 * Sets up the container columns.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 * 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
6272 * 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
6273 * 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
6274 * 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
6275 * 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
6276 * (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
6277 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278 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
6279 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6280 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6281 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6282 int z;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6283 DWContainer *cont = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6284
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6285 [cont setup];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6286
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6287 for(z=0;z<count;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6288 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6289 NSTableColumn *column = [[NSTableColumn alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6290 [[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
6291 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
6292 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6293 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
6294 [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
6295 [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
6296 }
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
6297 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
6298 {
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6299 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
6300 [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
6301 [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
6302 }
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
6303 /* 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
6304 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
6305 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6306 [(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
6307 [(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
6308 }
0103a8751ab4 Removed an unnecessary method in the container (rowCount) and implemented container column alignment.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 854
diff changeset
6309 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
6310 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6311 [(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
6312 [(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
6313 }
795
f23cad02cfb3 Make listbox, container and tree cells uneditable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 794
diff changeset
6314 [column setEditable:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6315 [cont addTableColumn:column];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6316 [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
6317 [column release];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6318 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6319 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
6320 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 /*
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6324 * Configures the main filesystem columnn title for localization.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6325 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6326 * handle: Handle to the container to be configured.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6327 * title: The title to be displayed in the main column.
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6328 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6329 void API dw_filesystem_set_column_title(HWND handle, char *title)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6330 {
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6331 char *newtitle = strdup(title ? title : "");
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6332
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6333 dw_window_set_data(handle, "_dw_coltitle", newtitle);
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6334 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6335
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6336 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 * 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
6338 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 * 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
6340 * 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
6341 * 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
6342 * 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
6343 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 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
6345 {
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
6346 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
6347 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6348 char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
813
7fa26d8cc8d0 Fix for column click handler not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 812
diff changeset
6349 DWContainer *cont = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6350
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6351 newtitles[0] = coltitle ? coltitle : "Filename";
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
6352
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
6353 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
6354
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
6355 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
6356 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
6357
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
6358 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
6359 [cont setFilesystem:YES];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6360
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6361 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6362 {
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6363 dw_window_set_data(handle, "_dw_coltitle", NULL);
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6364 free(coltitle);
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1740
diff changeset
6365 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6366 free(newtitles);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6367 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
6368 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 * 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
6373 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374 * 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
6375 * 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
6376 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 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
6378 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6379 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6380 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6381 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6382 [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
6383 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6384 return cont;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 * 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
6389 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 * 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
6391 * 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
6392 * 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
6393 * 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
6394 * 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
6395 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 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
6397 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6398 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6399 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6400 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6401 id object = nil;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6402 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
6403 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
6404
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
6405 /* 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
6406 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
6407 {
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
6408 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
6409 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6410
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6411 if(data)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6412 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6413 if(type & DW_CFA_BITMAPORICON)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6414 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6415 object = *((NSImage **)data);
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6416 }
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6417 else if(type & DW_CFA_STRING)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6418 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6419 char *str = *((char **)data);
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6420 object = [ NSString stringWithUTF8String:str ];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6421 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6422 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6423 {
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6424 char textbuffer[101] = {0};
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6425
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6426 if(type & DW_CFA_ULONG)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6427 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6428 ULONG tmp = *((ULONG *)data);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6429
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6430 snprintf(textbuffer, 100, "%lu", tmp);
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6431 }
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6432 else if(type & DW_CFA_DATE)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6433 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6434 struct tm curtm;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6435 CDATE cdate = *((CDATE *)data);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6436
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6437 memset( &curtm, 0, sizeof(curtm) );
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6438 curtm.tm_mday = cdate.day;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6439 curtm.tm_mon = cdate.month - 1;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6440 curtm.tm_year = cdate.year - 1900;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6441
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6442 strftime(textbuffer, 100, "%x", &curtm);
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6443 }
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6444 else if(type & DW_CFA_TIME)
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6445 {
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6446 struct tm curtm;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6447 CTIME ctime = *((CTIME *)data);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6448
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6449 memset( &curtm, 0, sizeof(curtm) );
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6450 curtm.tm_hour = ctime.hours;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6451 curtm.tm_min = ctime.minutes;
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6452 curtm.tm_sec = ctime.seconds;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6453
1502
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6454 strftime(textbuffer, 100, "%X", &curtm);
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6455 }
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6456 if(textbuffer[0])
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6457 object = [ NSString stringWithUTF8String:textbuffer ];
dc41efe8a53f Allow passing NULL to dw_container_change/set_item() APIs on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
6458 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6459 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
6460
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6461 [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
6462 [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
6463 DW_MUTEX_UNLOCK;
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 * 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
6468 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 * 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
6470 * 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
6471 * 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
6472 * 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
6473 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 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
6475 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6476 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
6477 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 * 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
6481 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6482 * 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
6483 * 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
6484 * 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
6485 * 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
6486 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 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
6488 {
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
6489 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
6490 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 * 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
6494 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 * 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
6496 * 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
6497 * 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
6498 * 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
6499 * 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
6500 */
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
6501 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
6502 {
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
6503 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
6504 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 * 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
6508 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 * 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
6510 * 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
6511 * 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
6512 * 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
6513 * 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
6514 */
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
6515 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
6516 {
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
6517 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
6518 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
6519 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
6520 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
6521 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
6522
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
6523 /* 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
6524 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
6525 {
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
6526 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
6527 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6528
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
6529 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
6530 [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
6531 [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
6532 [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
6533 [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
6534 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6535 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538 * 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
6539 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6540 * 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
6541 * 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
6542 * 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
6543 * 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
6544 * 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
6545 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 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
6547 {
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
6548 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
6549 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 * 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
6553 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 * 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
6555 * column: Zero based column.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 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
6558 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6559 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6560 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
6561 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
6562 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
6563 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
6564 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
6565 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
6566 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
6567 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
6568 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
6569 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
6570 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
6571 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
6572 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
6573 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
6574 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
6575 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
6576 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
6577 return rc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581 * 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
6582 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 * 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
6584 * column: Zero based column.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 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
6587 {
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
6588 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
6589 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 /*
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6592 * 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
6593 * Parameters:
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6594 * 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
6595 * 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
6596 * 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
6597 * 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
6598 * 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
6599 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1288
diff changeset
6600 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor)
1206
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6601 {
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6602 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
6603 DW_MUTEX_LOCK;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6604 DWContainer *cont = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6605 [cont setRowBgOdd:(oddcolor == DW_CLR_DEFAULT ? DW_RGB(230,230,230) : oddcolor)
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1210
diff changeset
6606 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
6607 DW_MUTEX_UNLOCK;
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6608 }
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6609
c7bb48cda53a Switched from using NSBrowserCell to a DWImageAndTextCell subclass on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1204
diff changeset
6610 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 * 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
6612 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 * 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
6614 * 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
6615 * width: Width of column in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 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
6618 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6619 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6620 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
6621 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
6622 if([cont filesystem])
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
6623 {
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
6624 column++;
168b9db65825 Minor fix for dw_container_column_set_width() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 829
diff changeset
6625 }
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
6626 NSTableColumn *col = [cont getColumn:column];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6627
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
6628 [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
6629 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6630 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6631
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6632 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6633 * 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
6634 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6635 * 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
6636 * 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
6637 * title: String title of the item.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 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
6640 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6641 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6642 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6643 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
6644 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
6645 [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
6646 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
6647 }
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
6648
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
6649
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
6650 /*
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
6651 * 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
6652 * 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
6653 * 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
6654 * 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
6655 * 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
6656 */
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
6657 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
6658 {
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
6659 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
6660 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
6661 DWContainer *cont = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6662 [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
6663 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667 * 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
6668 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669 * 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
6670 * 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
6671 * 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
6672 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 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
6674 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6675 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6676 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6677 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
6678 [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
6679 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 * Removes all rows from a container.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6685 * 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
6686 * 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
6687 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 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
6689 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6690 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6691 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6692 DWContainer *cont = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6693 [cont clear];
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6694 if(redraw)
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6695 {
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6696 [cont reloadData];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
6697 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6698 DW_MUTEX_UNLOCK;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6702 * 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
6703 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6704 * 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
6705 * 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
6706 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 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
6708 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6709 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6710 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
6711 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
6712 int x;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6713
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
6714 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
6715 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6716 [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
6717 }
1705
3fa0448d3a7e Fixed a bug in dw_container_delete_row() on Mac and potentially a similar bug in dw_container_delete().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6718 [cont 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
6719 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721
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 * Scrolls container up or down.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * 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
6726 * 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
6727 * 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
6728 * 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
6729 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 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
6731 {
837
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
6732 DWContainer *cont = handle;
89d4bad9c96e Initial attempt at implementing the scrollbox on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 831
diff changeset
6733 NSScrollView *sv = [cont scrollview];
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6734 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
6735 int rowcount = (int)[cont numberOfRowsInTableView:cont];
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6736 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
6737 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
6738
853
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6739 /* Safety check */
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6740 if(rowcount < 1)
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6741 {
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6742 return;
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6743 }
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
6744
853
c27ce204302b Add safety check to avoid potential divide by zero.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 852
diff changeset
6745 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
6746
852
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6747 switch(direction)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6748 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6749 case DW_SCROLL_TOP:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6750 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6751 [scrollbar setFloatValue:0];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6752 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6753 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6754 case DW_SCROLL_BOTTOM:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6755 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6756 [scrollbar setFloatValue:1];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6757 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6758 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6759 case DW_SCROLL_UP:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6760 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6761 float newpos = currpos - change;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6762 if(newpos < 0)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6763 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6764 newpos = 0;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6765 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6766 [scrollbar setFloatValue:newpos];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6767 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6768 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6769 case DW_SCROLL_DOWN:
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6770 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6771 float newpos = currpos + change;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6772 if(newpos > 1)
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6773 {
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6774 newpos = 1;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6775 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6776 [scrollbar setFloatValue:newpos];
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6777 break;
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6778 }
bb582f89007a Implemented dw_container_scroll() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 851
diff changeset
6779 }
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 * 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
6784 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 * 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
6786 * 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
6787 * 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
6788 * 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
6789 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6790 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
6791 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6792 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6793 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
6794 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
6795 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
6796 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
6797 char *retval = NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6798
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
6799 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
6800 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6801 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
6802 [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
6803 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6804 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6805 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6808 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6809 * 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
6810 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6811 * 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
6812 * 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
6813 * 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
6814 * 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
6815 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6816 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
6817 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6818 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6819 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
6820 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
6821 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
6822 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
6823 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
6824 char *retval = NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6825
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
6826 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
6827 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6828 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
6829 [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
6830 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6831 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6832 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6833 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6834
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6835 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6836 * 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
6837 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6838 * 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
6839 * 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
6840 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6841 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
6842 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6843 int _locked_by_me = FALSE;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6844 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6845 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
6846 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
6847 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
6848 int x, count = (int)[cont numberOfRowsInTableView:cont];
1322
3f1ac800bf65 Initial fix for being able to do container string comparisons instead of pointer on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1318
diff changeset
6849 int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6850
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
6851 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
6852 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6853 thistext = [cont getRowTitle:x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6854
1322
3f1ac800bf65 Initial fix for being able to do container string comparisons instead of pointer on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1318
diff changeset
6855 if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
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
6856 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6857 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6858
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
6859 [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
6860 [selected release];
1334
5e2ec37d1680 Attempt to make dw_container_cursor() scroll to the item on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
6861 [cont scrollRowToVisible:x];
1335
44f8a846f3c1 A couple minor code cleanups on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1334
diff changeset
6862 DW_MUTEX_UNLOCK;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6863 DW_LOCAL_POOL_OUT;
1335
44f8a846f3c1 A couple minor code cleanups on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1334
diff changeset
6864 return;
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
6865 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6866 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6867 DW_MUTEX_UNLOCK;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6868 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6869 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6870
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 * 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
6873 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * handle: Handle to the window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * 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
6876 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 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
6878 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6879 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6880 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
6881 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
6882 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
6883 int x, count = (int)[cont numberOfRowsInTableView:cont];
1322
3f1ac800bf65 Initial fix for being able to do container string comparisons instead of pointer on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1318
diff changeset
6884 int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6885
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
6886 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
6887 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6888 thistext = [cont getRowTitle:x];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
6889
1322
3f1ac800bf65 Initial fix for being able to do container string comparisons instead of pointer on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1318
diff changeset
6890 if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
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
6891 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6892 [cont removeRow:x];
1705
3fa0448d3a7e Fixed a bug in dw_container_delete_row() on Mac and potentially a similar bug in dw_container_delete().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6893 [cont reloadData];
1335
44f8a846f3c1 A couple minor code cleanups on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1334
diff changeset
6894 DW_MUTEX_UNLOCK;
675
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6895 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
6896 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
6897 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6898 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902 * 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
6903 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 * 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
6905 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906 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
6907 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6908 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6909 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6910 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
6911 [cont optimize];
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
6912 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 * Inserts an icon into the taskbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6918 * 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
6919 * 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
6920 * 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
6921 */
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
6922 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
6923 {
1220
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6924 NSStatusItem *item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6925 NSImage *image = icon;
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6926 [item setImage:image];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6927 if(bubbletext)
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6928 [item setToolTip:[NSString stringWithUTF8String:bubbletext]];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6929 [item setTarget:handle];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6930 [item setEnabled:YES];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6931 [item setHighlightMode:YES];
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6932 [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)];
1222
aac69b11e821 Fix to get button press events working from the task/statusbar on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1220
diff changeset
6933 [item setAction:@selector(mouseDown:)];
1220
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6934 dw_window_set_data(handle, "_dw_taskbar", item);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 * Deletes an icon from the taskbar.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 * 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
6941 * 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
6942 */
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
6943 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
6944 {
1220
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6945 NSStatusItem *item = dw_window_get_data(handle, "_dw_taskbar");
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6946 DW_LOCAL_POOL_IN;
1220
67ff39b9577c Initial implementation of dw_taskbar_* for the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1215
diff changeset
6947 [item release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
6948 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950
1708
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6951 /* Internal function to keep HICNs from getting too big */
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6952 void _icon_resize(NSImage *image)
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6953 {
1709
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6954 if(image)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6955 {
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6956 NSSize size = [image size];
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6957 if(size.width > 24 || size.height > 24)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6958 {
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6959 if(size.width > 24)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6960 size.width = 24;
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6961 if(size.height > 24)
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6962 size.height = 24;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
6963 [image setSize:size];
1709
de49c1f284b2 Safety check for the icon resize code on Mac and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1708
diff changeset
6964 }
1708
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6965 }
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6966 }
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6967
1713
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6968 /* Internal version that does not resize the image */
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6969 HICN _dw_icon_load(unsigned long resid)
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6970 {
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6971 NSBundle *bundle = [NSBundle mainBundle];
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6972 NSString *respath = [bundle resourcePath];
1770
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
6973 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
1713
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6974 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6975 return image;
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6976 }
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6977
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 * 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
6980 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 * 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
6982 * 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
6983 * 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
6984 * to an embedded XPM.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 */
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
6986 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
6987 {
1713
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
6988 NSImage *image = _dw_icon_load(resid);
1708
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
6989 _icon_resize(image);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
6990 return image;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 * Obtains an icon from a file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996 * 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
6997 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 * (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
6999 */
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
7000 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
7001 {
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7002 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
7003
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
7004 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
7005 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
7006 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
7007 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7008 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
7009 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
7010 }
1708
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
7011 _icon_resize(image);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7012 return image;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7013 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7014
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7016 * Obtains an icon from data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018 * 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
7019 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020 * (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
7021 */
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
7022 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
7023 {
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7024 NSData *thisdata = [NSData dataWithBytes:data length:len];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7025 NSImage *image = [[NSImage alloc] initWithData:thisdata];
1708
cc10082567ed Similar code for Mac to keep HICNs from getting too big.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1705
diff changeset
7026 _icon_resize(image);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7027 return image;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 * 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
7032 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7033 * 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
7034 */
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
7035 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
7036 {
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
7037 NSImage *image = handle;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7038 DW_LOCAL_POOL_IN;
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
7039 [image release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7040 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 * 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
7045 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 * 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
7047 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7048 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
7049 {
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
7050 /* 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
7051 * 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
7052 * when the application is deactivated to simulate
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7053 * 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
7054 */
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
7055 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
7056 /* [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
7057 return mdi;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7059
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7060 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 * 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
7062 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 * 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
7064 * 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
7065 * 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
7066 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7067 * 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
7068 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7069 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
7070 {
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7071 id 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
7072 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7073 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7074 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
7075 [split setDelegate:split];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
7076 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
7077 [split addSubview:tmpbox];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7078 [tmpbox autorelease];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7079 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
7080 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
7081 [split addSubview:tmpbox];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7082 [tmpbox autorelease];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7083 if(type == DW_VERT)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7084 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7085 [split setVertical:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7086 }
668
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
7087 else
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
7088 {
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
7089 [split setVertical:YES];
7b99731c6484 Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 667
diff changeset
7090 }
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
7091 /* 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
7092 [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
7093 /* [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
7094 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7095 return split;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7096 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7097
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7098 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099 * 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
7100 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101 * 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
7102 * 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
7103 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7104 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
7105 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7106 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
7107 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7108 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
7109 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
7110 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
7111 /* 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
7112 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
7113 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7114 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
7115 }
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7116 else
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7117 {
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7118 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
7119 }
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7120 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
7121 {
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7122 [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
7123 }
676
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7124 else
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7125 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7126 /* 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
7127 * 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
7128 * 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
7129 */
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7130 [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
7131 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7132 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7134
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7136 * 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
7137 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7138 * 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
7139 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 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
7141 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7142 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
7143 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
7144 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
7145 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
7146 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
7147 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
7148 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
7149 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7150 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
7151 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
7152 }
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7153 else
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7154 {
677
99002595f549 Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 676
diff changeset
7155 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
7156 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
7157 }
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7158 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
7159 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
7160 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
7161 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7162 return retval;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7163 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7164
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
7165 /* 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
7166 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
7167 {
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
7168 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
7169 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
7170 NSFont *font = nil;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7171
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
7172 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
7173 {
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
7174 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
7175 *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
7176 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
7177 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
7178 }
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
7179 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
7180 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
7181 }
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
7182
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7184 * 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
7185 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7186 * 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
7187 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7188 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
7189 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7190 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7191 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7192 NSImageView *bitmap = [[NSImageView alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7193 [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
7194 [bitmap setImageScaling:NSScaleNone];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7195 [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
7196 [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
7197 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7198 return bitmap;
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 * Creates a pixmap with given parameters.
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: 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
7205 * 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
7206 * 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
7207 * depth: Color depth of the pixmap.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 * 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
7210 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7211 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
7212 {
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
7213 HPIXMAP pixmap;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7214
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
7215 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
7216 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
7217 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
7218 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
7219 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
7220 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
7221 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
7222 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
7223 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
7224 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
7225 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
7226 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
7227 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
7228 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
7229 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
7230 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
7231 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7232 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7233
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7234 /* 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
7235 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
7236 {
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7237 [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
7238 [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
7239 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
7240 flipped:YES]];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
7241 [[[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil] autorelease];
1590
9eef6f82ee50 Comment cleanup in the Mac source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1586
diff changeset
7242 /* Make a new transform */
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7243 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
7244
1590
9eef6f82ee50 Comment cleanup in the Mac source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1586
diff changeset
7245 /* By scaling Y negatively, we effectively flip the image */
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7246 [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
7247
1590
9eef6f82ee50 Comment cleanup in the Mac source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1586
diff changeset
7248 /* But we also have to translate it back by its height */
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7249 [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
7250
1590
9eef6f82ee50 Comment cleanup in the Mac source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1586
diff changeset
7251 /* Apply the transform */
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7252 [t concat];
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7253 [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
7254 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
7255 [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
7256 }
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7257
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 * Creates a pixmap from a file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 * 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
7262 * 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
7263 * DW pick the appropriate file extension.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7264 * (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
7265 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7266 * 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
7267 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7268 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
7269 {
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
7270 HPIXMAP pixmap;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7271 DW_LOCAL_POOL_IN;
938
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7272 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
7273
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
7274 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7275 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7276 DW_LOCAL_POOL_OUT;
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
7277 return NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7278 }
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
7279 NSString *nstr = [ NSString stringWithUTF8String:filename ];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
7280 NSImage *tmpimage = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7281 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
7282 {
cfcf66a90e8c Add support for different image file types in dw_*_from_file() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 937
diff changeset
7283 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
7284 tmpimage = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7285 }
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7286 if(!tmpimage)
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7287 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7288 DW_LOCAL_POOL_OUT;
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7289 return NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7290 }
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7291 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
7292 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
7293 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
7294 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
7295 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
7296 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
7297 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
7298 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
7299 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
7300 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
7301 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
7302 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
7303 _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
7304 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
7305 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
7306 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
7307 pixmap->handle = handle;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7308 DW_LOCAL_POOL_OUT;
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
7309 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7310 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7311
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7312 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7313 * Creates a pixmap from memory.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 * 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
7316 * data: Source of the image data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 * (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
7318 * le: length of data
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7320 * 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
7321 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322 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
7323 {
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
7324 HPIXMAP pixmap;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7325 DW_LOCAL_POOL_IN;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7326
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
7327 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7328 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7329 DW_LOCAL_POOL_OUT;
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
7330 return NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7331 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7332 NSData *thisdata = [NSData dataWithBytes:data length:len];
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
7333 NSImage *tmpimage = [[[NSImage alloc] initWithData:thisdata] autorelease];
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7334 if(!tmpimage)
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7335 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7336 DW_LOCAL_POOL_OUT;
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7337 return NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7338 }
957
beed3e7f9d4b Fixes to flip pixmaps when loading from file or data on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 954
diff changeset
7339 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
7340 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
7341 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
7342 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
7343 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
7344 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
7345 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
7346 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
7347 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
7348 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
7349 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
7350 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
7351 _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
7352 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
7353 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
7354 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
7355 pixmap->handle = handle;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7356 DW_LOCAL_POOL_OUT;
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
7357 return pixmap;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7358 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7359
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7360 /*
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
7361 * 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
7362 * 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
7363 * 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
7364 * 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
7365 * 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
7366 * 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
7367 * is handled automatically
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7368 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7369 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
7370 {
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
7371 /* Don't do anything */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 * 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
7376 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377 * 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
7378 * 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
7379 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 * 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
7381 */
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
7382 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
7383 {
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
7384 HPIXMAP pixmap;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7385 DW_LOCAL_POOL_IN;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7386
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
7387 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7388 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7389 DW_LOCAL_POOL_OUT;
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
7390 return NULL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7391 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7392
670
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
7393 NSBundle *bundle = [NSBundle mainBundle];
0b920d0dc13e Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 669
diff changeset
7394 NSString *respath = [bundle resourcePath];
1770
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
7395 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
1318
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7396 NSImage *temp = [[NSImage alloc] initWithContentsOfFile:filepath];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7397
1318
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7398 if(temp)
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7399 {
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7400 NSSize size = [temp size];
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7401 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7402 initWithBitmapDataPlanes:NULL
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7403 pixelsWide:size.width
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7404 pixelsHigh:size.height
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7405 bitsPerSample:8
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7406 samplesPerPixel:4
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7407 hasAlpha:YES
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7408 isPlanar:NO
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7409 colorSpaceName:NSDeviceRGBColorSpace
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7410 bytesPerRow:0
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7411 bitsPerPixel:0];
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7412 _flip_image(temp, image, size);
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7413 pixmap->width = size.width;
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7414 pixmap->height = size.height;
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7415 pixmap->image = image;
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7416 pixmap->handle = handle;
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7417 [temp release];
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7418 return pixmap;
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7419 }
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7420 free(pixmap);
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7421 DW_LOCAL_POOL_OUT;
1318
ebd67be26f43 Fixed some issues and deprecations building with Xcode 4.2 on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1314
diff changeset
7422 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424
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
7425 /*
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
7426 * 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
7427 * 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
7428 * 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
7429 * 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
7430 * 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
7431 * 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
7432 * 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
7433 * 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
7434 * 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
7435 */
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
7436 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
7437 {
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
7438 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
7439 {
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
7440 NSFont *font = _dw_font_by_name(fontname);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7441
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
7442 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
7443 {
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7444 DW_LOCAL_POOL_IN;
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
7445 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
7446 [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
7447 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
7448 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
7449 [oldfont release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7450 DW_LOCAL_POOL_OUT;
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
7451 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
7452 }
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
7453 }
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
7454 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
7455 }
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
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 * Destroys an allocated pixmap.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7459 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 * 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
7461 * dw_pixmap_new..
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7463 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
7464 {
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
7465 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
7466 {
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
7467 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
7468 NSFont *font = pixmap->font;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7469 DW_LOCAL_POOL_IN;
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
7470 [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
7471 [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
7472 free(pixmap);
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7473 DW_LOCAL_POOL_OUT;
981
536ec60ee433 Don't destroy a pixmap if the handle is null
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 980
diff changeset
7474 }
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 * Copies from one item to another.
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 * dest: Destination window handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * destp: Destination pixmap. (choose only one).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 * xdest: X coordinate of destination.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7483 * ydest: Y coordinate of destination.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 * width: Width of area to copy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7485 * height: Height of area to copy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7486 * src: Source window handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7487 * srcp: Source pixmap. (choose only one).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7488 * xsrc: X coordinate of source.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 * ysrc: Y coordinate of source.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491 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
7492 {
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7493 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7494 }
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7495
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7496 /*
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7497 * Copies from one surface to another allowing for stretching.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7498 * Parameters:
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7499 * dest: Destination window handle.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7500 * destp: Destination pixmap. (choose only one).
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7501 * xdest: X coordinate of destination.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7502 * ydest: Y coordinate of destination.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7503 * width: Width of the target area.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7504 * height: Height of the target area.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7505 * src: Source window handle.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7506 * srcp: Source pixmap. (choose only one).
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7507 * xsrc: X coordinate of source.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7508 * ysrc: Y coordinate of source.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7509 * srcwidth: Width of area to copy.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7510 * srcheight: Height of area to copy.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7511 * Returns:
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7512 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7513 */
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7514 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7515 {
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
7516 DWBitBlt *bltinfo = calloc(1, sizeof(DWBitBlt));
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7517 NSValue* bi;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7518 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7519
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7520 bi = [NSValue valueWithPointer:bltinfo];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7521
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7522 /* Sanity checks */
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7523 if((!dest && !destp) || (!src && !srcp) ||
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7524 ((srcwidth == -1 || srcheight == -1) && srcwidth != srcheight))
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7525 {
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7526 DW_LOCAL_POOL_OUT;
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7527 return DW_ERROR_GENERAL;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7528 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7529
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
7530 /* 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
7531 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
7532 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
7533 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
7534 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
7535 bltinfo->width = width;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7536 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
7537 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
7538 bltinfo->ysrc = ysrc;
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7539 bltinfo->srcwidth = srcwidth;
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7540 bltinfo->srcheight = srcheight;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7541
699
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
7542 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
7543 {
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
7544 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
7545 }
b79300831495 Offload some drawing functions to the main thread to prevent focus deadlocks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 698
diff changeset
7546 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
7547 {
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
7548 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
7549 [object retain];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7550 }
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7551 if(DWThread == (DWTID)-1)
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7552 [DWObj doBitBlt:bi];
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7553 else
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7554 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES];
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
7555 DW_LOCAL_POOL_OUT;
1247
93607596cf85 Implemented dw_pixmap_stretch_bitblt() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1241
diff changeset
7556 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * 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
7561 * Not available under OS/2, eCS
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 * 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
7564 * 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
7565 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7566 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
7567 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
7568 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
7569 [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
7570 [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
7571 [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
7572 [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
7573 [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
7574 return calendar;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7576
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7578 * 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
7579 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7580 * 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
7581 * year...
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583 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
7584 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
7585 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
7586 NSDate *date;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
7587 char buffer[101];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7588 DW_LOCAL_POOL_IN;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
7589
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
7590 snprintf(buffer, 100, "%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
7591
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
7592 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
7593 [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
7594 [date release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7595 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7597
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7598 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 * 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
7600 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7601 * 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
7602 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7603 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
7604 {
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
7605 DWCalendar *calendar = handle;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7606 DW_LOCAL_POOL_IN;
729
6712e4211522 Switched to graphical calendar control style... and fixed date querying code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 728
diff changeset
7607 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
7608 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
7609 [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
7610 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
7611 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
7612 if(*year < 70)
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
7613 {
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7614 *year += 2000;
730
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
7615 }
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
7616 else if(*year < 100)
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7617 {
730
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
7618 *year += 1900;
d3fb3613726a Calendar control should return years with 4 digits not 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 729
diff changeset
7619 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7620 [df release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7621 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7622 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7623
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7624 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7625 * 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
7626 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7627 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7628 * 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
7629 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7630 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
7631 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7632 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7633 switch(action)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7634 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7635 case DW_HTML_GOBACK:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7636 [html goBack];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7637 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7638 case DW_HTML_GOFORWARD:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7639 [html goForward];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7640 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7641 case DW_HTML_GOHOME:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7642 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7643 case DW_HTML_SEARCH:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7644 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7645 case DW_HTML_RELOAD:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7646 [html reload:html];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7647 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7648 case DW_HTML_STOP:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7649 [html stopLoading:html];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7650 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7651 case DW_HTML_PRINT:
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7652 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7653 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7657 * 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
7658 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 * 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
7661 * be rendered.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7663 * 0 on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665 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
7666 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7667 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7668 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7669 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7670 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7671
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7672 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7673 * 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
7674 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7675 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7676 * 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
7677 * file object to be rendered.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7678 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7679 * 0 on success.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7680 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7681 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
7682 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7683 WebView *html = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7684 [[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
7685 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7686 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7687
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7688 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7689 * 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
7690 * Not available under OS/2, eCS
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7691 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7692 * 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
7693 * 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
7694 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7695 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
7696 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7697 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
7698 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7699 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
7700 /* [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
7701 DW_MUTEX_UNLOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7702 return web;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704
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 * 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
7707 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 * 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
7709 * 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
7710 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 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
7712 {
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7713 NSPoint mouseLoc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7714 mouseLoc = [NSEvent mouseLocation];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7715 if(x)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7716 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7717 *x = mouseLoc.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7718 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7719 if(y)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7720 {
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
7721 *y = [[NSScreen mainScreen] frame].size.height - mouseLoc.y;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7722 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7723 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7724
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7725 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7726 * 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
7727 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7728 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7729 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7730 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7731 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
7732 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7733 /* 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
7734 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7735
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7736 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7737 * 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
7738 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7739 * 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
7740 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7741 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7742 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
7743 {
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7744 NSMenu *menu = [[NSMenu alloc] init];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7745 [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
7746 /* [menu setTag:cid]; Why doesn't this work? */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7747 return menu;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751 * Create a menubar on a window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7752 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753 * 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
7754 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7755 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
7756 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7757 NSWindow *window = location;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7758 NSMenu *windowmenu = _generate_main_menu();
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7759 [[window contentView] setMenu:windowmenu];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7760 return (HMENUI)windowmenu;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7761 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7762
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7763 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7764 * 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
7765 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7766 * menu: Handle of a menu.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7767 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7768 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
7769 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7770 NSMenu *thismenu = *menu;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7771 DW_LOCAL_POOL_IN;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7772 [thismenu release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
7773 DW_LOCAL_POOL_OUT;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 * 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
7778 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 * 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
7780 * 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
7781 * x: X coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7782 * y: Y coordinate.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7783 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784 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
7785 {
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
7786 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
7787 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
7788 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
7789 NSWindow *window = [view window];
701
c91a1b345f2e Fix for button press and context menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 700
diff changeset
7790 NSEvent *event = [DWApp currentEvent];
1225
f5b79d8b0694 Fixed positioning popup menu when the controlling window is not visible on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1222
diff changeset
7791 if(!window)
f5b79d8b0694 Fixed positioning popup menu when the controlling window is not visible on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1222
diff changeset
7792 window = [event window];
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7793 [thismenu autorelease];
946
c64d3ca566f9 Attempt at inverting the window position and mouse pointer coordinates on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 945
diff changeset
7794 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
7795 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
7796 location:[window convertScreenToBase:p]
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7797 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
7798 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
7799 windowNumber:[window windowNumber]
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7800 context:[NSGraphicsContext currentContext]
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7801 eventNumber:1
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7802 clickCount:1
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
7803 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
7804 [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
7805 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7806
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7807 char _removetilde(char *dest, char *src)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7808 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7809 int z, cur=0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7810 char accel = '\0';
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7811
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7812 for(z=0;z<strlen(src);z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7813 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7814 if(src[z] != '~')
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7815 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7816 dest[cur] = src[z];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7817 cur++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7818 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7819 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7820 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7821 accel = src[z+1];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7822 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7823 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7824 dest[cur] = 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7825 return accel;
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 * 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
7830 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 * 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
7832 * 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
7833 * 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
7834 * 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
7835 * 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
7836 * 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
7837 * 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
7838 * 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
7839 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
7840 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
7841 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7842 NSMenu *menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7843 NSMenu *submenu = submenux;
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
7844 DWMenuItem *item = NULL;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7845 if(strlen(title) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7846 {
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
7847 [menu addItem:[DWMenuItem separatorItem]];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7848 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7849 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7850 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7851 char accel[2];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7852 char *newtitle = malloc(strlen(title)+1);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7853 NSString *nstr;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7854
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7855 accel[0] = _removetilde(newtitle, title);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7856 accel[1] = 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7857
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7858 nstr = [ NSString stringWithUTF8String:newtitle ];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7859 free(newtitle);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7860
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7861 item = [[[DWMenuItem alloc] initWithTitle:nstr
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
7862 action:@selector(menuHandler:)
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
7863 keyEquivalent:[ NSString stringWithUTF8String:accel ]] autorelease];
1312
c5db6c70905c Added code to remove signal handlers when objects are destroyed on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
7864 [menu addItem:item];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7865
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7866 [item setTag:itemid];
1517
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7867 if(check)
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7868 {
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7869 [item setCheck:YES];
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7870 if(flags & DW_MIS_CHECKED)
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7871 {
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7872 [item setState:NSOnState];
6506f29dfefc Implement automatic checking and unchecking of menu items on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1513
diff changeset
7873 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7874 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7875 if(flags & DW_MIS_DISABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7876 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7877 [item setEnabled:NO];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7878 }
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7879
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7880 if(submenux)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7881 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7882 [submenu setTitle:nstr];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7883 [menu setSubmenu:submenu forItem:item];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7884 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7885 return item;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7886 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7887 return item;
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 * 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
7892 * 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
7893 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7894 * 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
7895 * id: Menuitem id.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896 * 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
7897 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
7898 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
7899 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7900 id menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7901 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
7902
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7903 if(menuitem != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7904 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7905 if(check)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7906 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7907 [menuitem setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7908 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7909 else
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
7910 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7911 [menuitem setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7912 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7913 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 /*
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7917 * Deletes the menu item specified.
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7918 * Parameters:
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7919 * menu: The handle to the menu in which the item was appended.
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7920 * id: Menuitem id.
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7921 * Returns:
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7922 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7923 */
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7924 int API dw_menu_delete_item(HMENUI menux, unsigned long itemid)
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7925 {
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7926 id menu = menux;
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7927 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
7928
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7929 if(menuitem != nil)
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7930 {
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7931 [menu removeItem:menuitem];
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7932 return DW_ERROR_NONE;
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7933 }
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7934 return DW_ERROR_UNKNOWN;
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7935 }
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7936
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
7937 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7938 * 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
7939 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7940 * 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
7941 * id: Menuitem id.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7942 * 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
7943 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7944 */
654
80e253df49fd Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 653
diff changeset
7945 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
7946 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7947 id menu = menux;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7948 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
7949
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7950 if(menuitem != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7951 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7952 if(state & DW_MIS_CHECKED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7953 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7954 [menuitem setState:NSOnState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7955 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7956 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
7957 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7958 [menuitem setState:NSOffState];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7959 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7960 if(state & DW_MIS_ENABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7961 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7962 [menuitem setEnabled:YES];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7963 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7964 else if(state & DW_MIS_DISABLED)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7965 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7966 [menuitem setEnabled:NO];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7967 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7968 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7969 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970
652
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
7971 /* 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
7972 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
7973 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7974 NSArray *pages = [notebook tabViewItems];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7975 for(DWNotebookPage *notepage in pages)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7976 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7977 if([notepage pageid] == pageid)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7978 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7979 return notepage;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7980 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7981 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7982 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
7983 }
ef0f484c6c4b Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 651
diff changeset
7984
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986 * 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
7987 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 * 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
7989 * resource file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7990 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
7991 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
7992 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7993 DWNotebook *notebook = [[DWNotebook alloc] init];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7994 [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
7995 /* [notebook setTag:cid]; Why doesn't this work? */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
7996 return notebook;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7999 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8000 * 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
8001 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8002 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8003 * flags: Any additional page creation flags.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8004 * 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
8005 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8006 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
8007 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8008 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8009 NSInteger page = [notebook pageid];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8010 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
8011 [notepage setPageid:(int)page];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8012 if(front)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8013 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8014 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8015 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8016 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8017 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8018 [notebook addTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8019 }
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
8020 [notepage autorelease];
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
8021 [notebook setPageid:(int)(page+1)];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8022 return (unsigned long)page;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8023 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8026 * Remove a page from a notebook.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8027 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8028 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8029 * 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
8030 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8031 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
8032 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8033 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8034 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid);
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
8035 DW_LOCAL_POOL_IN;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8036
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8037 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8038 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8039 [notebook removeTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8040 }
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
8041 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 * Queries the currently visible page ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8048 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 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
8050 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8051 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8052 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8053 return [notepage pageid];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8054 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8055
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8056 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8057 * Sets the currently visibale page ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8058 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8059 * handle: Handle to the notebook widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8060 * 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
8061 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8062 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
8063 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8064 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8065 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
8066
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8067 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8068 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8069 [notebook selectTabViewItem:notepage];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8070 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8071 }
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 * 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
8075 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8076 * handle: Notebook handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8077 * 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
8078 * 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
8079 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 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
8081 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8082 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8083 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
8084
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8085 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8086 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8087 [notepage setLabel:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8088 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8089 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090
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 * 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
8093 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8094 * handle: Notebook handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8095 * 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
8096 * 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
8097 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8098 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
8099 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8100 /* Note supported here... do nothing */
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102
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 * 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
8105 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 * 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
8107 * 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
8108 * page: Box handle to be packed.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110 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
8111 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8112 DWNotebook *notebook = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8113 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
8114
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8115 if(notepage != nil)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8116 {
667
28727d9a835c Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 666
diff changeset
8117 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
8118 DWBox *box = tmpbox;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8119
667
28727d9a835c Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 666
diff changeset
8120 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
8121 [notepage setView:box];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8122 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8123 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8124
1610
48a61abcd5bb Make sure source will build with Mac frameworks older than 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1607
diff changeset
8125 #ifndef NSWindowCollectionBehaviorFullScreenPrimary
48a61abcd5bb Make sure source will build with Mac frameworks older than 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1607
diff changeset
8126 #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7)
48a61abcd5bb Make sure source will build with Mac frameworks older than 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1607
diff changeset
8127 #endif
48a61abcd5bb Make sure source will build with Mac frameworks older than 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1607
diff changeset
8128
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8129 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8130 * Create a new Window Frame.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8131 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132 * 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
8133 * title: The Window title.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8134 * 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
8135 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136 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
8137 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8138 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8139 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
8140 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
8141 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
8142 initWithContentRect:frame
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8143 styleMask:(flStyle)
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
8144 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
8145 defer:false];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 [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
8148
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 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
8150
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 [window setContentView:view];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 [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
8153 [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
8154 [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
8155 [view release];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8156
1607
d7fcea7bfcf9 Add full screen support for resizable windows on Mac 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1593
diff changeset
8157 /* Enable full screen mode on resizeable windows */
d7fcea7bfcf9 Add full screen support for resizable windows on Mac 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1593
diff changeset
8158 if(flStyle & DW_FCF_SIZEBORDER)
d7fcea7bfcf9 Add full screen support for resizable windows on Mac 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1593
diff changeset
8159 {
d7fcea7bfcf9 Add full screen support for resizable windows on Mac 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1593
diff changeset
8160 [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
d7fcea7bfcf9 Add full screen support for resizable windows on Mac 10.7.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1593
diff changeset
8161 }
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8162
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
8163 /* 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
8164 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
8165 {
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
8166 id object = hwndOwner;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8167
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
8168 /* 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
8169 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
8170 {
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
8171 /* 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
8172 [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
8173 [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
8174 }
014b02436c1f Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 683
diff changeset
8175 }
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
8176 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
8177 return (HWND)window;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180 /*
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8181 * 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
8182 * Parameters:
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8183 * handle: Window handle of the widget.
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8184 * function: Function pointer to be called.
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8185 * 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
8186 */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8187 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
8188 {
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
8189 void **params = calloc(2, sizeof(void *));
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
8190 NSValue *v;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
8191 DW_LOCAL_POOL_IN;
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
8192 v = [NSValue valueWithPointer:params];
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
8193 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
8194 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
8195 [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
8196 free(params);
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
8197 DW_LOCAL_POOL_OUT;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8198 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8199
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8200
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
8201 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8202 * 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
8203 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8204 * 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
8205 * 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
8206 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8207 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
8208 {
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8209 id object = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8210
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8211 if([ object isKindOfClass:[ NSView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8212 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8213 NSView *view = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8214
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8215 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
8216 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8217 [view discardCursorRects];
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8218 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8219 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
8220 {
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8221 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
8222 NSCursor *cursor = [NSCursor arrowCursor];
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8223
669
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8224 [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
8225 }
62aae18e7b7d Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 668
diff changeset
8226 /* 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
8227 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 * Makes the window visible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 * 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
8234 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235 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
8236 {
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
8237 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8238
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8239 if([ object isMemberOfClass:[ DWWindow class ] ])
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8240 {
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8241 DWWindow *window = handle;
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8242 NSRect rect = [[window contentView] frame];
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8243 id defaultitem = [window initialFirstResponder];
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8244
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
8245 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
8246 {
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
8247 [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
8248 }
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
8249 /* If we haven't been sized by a call.. */
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8250 if(rect.size.width <= 1 || rect.size.height <= 1)
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8251 {
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8252 /* Determine the contents size */
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8253 dw_window_set_size(handle, 0, 0);
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8254 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8255 /* If the position was not set... generate a default
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8256 * default one in a similar pattern to SHELLPOSITION.
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8257 */
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8258 if(![window shown])
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8259 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8260 static int defaultx = 0, defaulty = 0;
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8261 int cx = dw_screen_width(), cy = dw_screen_height();
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8262 int maxx = cx / 4, maxy = cy / 4;
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8263 NSPoint point;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8264
1489
4c1c44af201a Added auto-positioning and auto-sizing code for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1478
diff changeset
8265 rect = [window frame];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8266
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8267 defaultx += 20;
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8268 defaulty += 20;
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8269 if(defaultx > maxx)
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8270 defaultx = 20;
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8271 if(defaulty > maxy)
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8272 defaulty = 20;
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8273
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8274 point.x = defaultx;
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8275 /* Take into account menu bar and inverted Y */
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8276 point.y = cy - defaulty - (int)rect.size.height - 22;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8277
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
8278 [window setFrameOrigin:point];
1490
5393b56ec6d0 Autoposition code should only be run the first time on Mac, regardless of whether it was needed or not.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1489
diff changeset
8279 [window setShown:YES];
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
8280 }
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
8281 [[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
8282 [window makeKeyAndOrderFront:nil];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8283
1782
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8284 if(!([window styleMask] & NSResizableWindowMask))
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8285 {
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8286 /* Fix incorrect repeat in displaying textured windows */
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8287 [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8288 [window setContentBorderThickness:0.0 forEdge:NSMinYEdge];
d056a50196a9 Attempted fix at Mac textured background repeat problems. Thanks to Christoph Sinai
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1779
diff changeset
8289 }
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8290 if(defaultitem)
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8291 {
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8292 /* If there is a default item set, make it first responder */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8293 [window makeFirstResponder:defaultitem];
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8294 }
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
8295 }
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
8296 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 * Makes the window invisible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8302 * 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
8303 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 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
8305 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8306 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8307
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8308 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8309 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8310 NSWindow *window = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8311
733
8d5e5b89725f Fixed the crashing issue with dw_color_choose() it now functions properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 732
diff changeset
8312 [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
8313 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8314 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316
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 * 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
8319 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 * 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
8322 * 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
8323 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8324 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
8325 {
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8326 id object = handle;
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8327 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
8328 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
8329 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
8330 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
8331
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
8332 /* 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
8333 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
8334 {
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
8335 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
8336 }
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
8337 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
8338 {
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
8339 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
8340 }
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
8341
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
8342 /* 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
8343 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
8344 {
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
8345 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
8346 }
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
8347 /* 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
8348 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
8349 {
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
8350 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
8351
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
8352 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
8353 {
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
8354 [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
8355 }
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
8356 }
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
8357 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
8358 {
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
8359 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
8360
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
8361 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
8362 {
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
8363 [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
8364 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8365 }
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8366 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
8367 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8368 DWBox *box = object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8369
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
8370 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
8371 {
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
8372 [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
8373 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8374 }
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
8375 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
8376 {
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
8377 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
8378
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
8379 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
8380 {
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
8381 [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
8382 }
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
8383 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
8384 {
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
8385 [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
8386 }
810
746cdd753e7a Added coloring support for the Container/Tree/Listbox controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 809
diff changeset
8387 }
1543
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
8388 else if([object isMemberOfClass:[DWMLE class]])
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
8389 {
b86a04751ea0 Refactor MLE code on Mac to be more like the Container and Tree code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1538
diff changeset
8390 DWMLE *mle = handle;
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
8391 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
8392 {
1130
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8393 [mle setBackgroundColor:bg];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8394 }
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8395 if(fg)
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8396 {
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8397 NSTextStorage *ts = [mle textStorage];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8398 [ts setForegroundColor:fg];
c3138ffd0de0 Implemented foreground color changes for MLE on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1129
diff changeset
8399 }
1128
7d7535f6bc4e Added ability to set background color of MLE; setting foreground still outstanding.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1120
diff changeset
8400 }
739
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8401 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 * 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
8406 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 * 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
8409 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 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
8411 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8412 return 0;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8415 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 * 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
8417 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8418 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8419 * width: New width in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8420 * height: New height in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8421 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8422 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
8423 {
1778
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8424 id object = _text_handle(handle);
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8425
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8426 if([object isMemberOfClass:[DWWindow class]])
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
8427 {
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
8428 DWWindow *window = object;
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8429 SEL sssm = NSSelectorFromString(@"setStyleMask");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8430
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8431 if([window respondsToSelector:sssm])
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8432 {
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8433 IMP issm = [window methodForSelector:sssm];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8434 int currentstyle = (int)[window styleMask];
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8435 int tmp;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8436
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8437 tmp = currentstyle | (int)mask;
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8438 tmp ^= mask;
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8439 tmp |= style;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8440
1773
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8441 issm(window, sssm, tmp);
da7786b8573f Check if classes respond to selectors on Mac for new, removed and deprecated methods to avoid compiler warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1772
diff changeset
8442 }
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
8443 }
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
8444 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
8445 {
bb3b2d804f0e Working on fonts some more.... setting a default label font that is smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 739
diff changeset
8446 NSTextField *tf = object;
1778
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8447 DWTextFieldCell *cell = [tf cell];
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8448
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8449 [cell setAlignment:(style & 0xF)];
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8450 if(mask & DW_DT_VCENTER && [cell isMemberOfClass:[DWTextFieldCell class]])
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8451 {
e71ab68198ce Minor cleanups for the Mac status text changes for 10.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1776
diff changeset
8452 [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
8453 }
1788
9d499b162fe1 Discovered a breakage in OS/2 functionality when building
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1786
diff changeset
8454 if(mask & DW_DT_WORDBREAK && [cell isMemberOfClass:[DWTextFieldCell class]])
9d499b162fe1 Discovered a breakage in OS/2 functionality when building
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1786
diff changeset
8455 {
9d499b162fe1 Discovered a breakage in OS/2 functionality when building
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1786
diff changeset
8456 [cell setWraps:(style & DW_DT_WORDBREAK ? YES : NO)];
9d499b162fe1 Discovered a breakage in OS/2 functionality when building
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1786
diff changeset
8457 }
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
8458 }
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
8459 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
8460 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
8461 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
8462 [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
8463 }
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
8464 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
8465 {
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
8466 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
8467
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
8468 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
8469 {
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
8470 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
8471 [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
8472 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
8473 [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
8474 }
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
8475 }
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8476 else if([object isMemberOfClass:[DWMenuItem class]])
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8477 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8478 if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8479 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8480 if(style & DW_MIS_CHECKED)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8481 [object setState:NSOnState];
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8482 else if(style & DW_MIS_UNCHECKED)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8483 [object setState:NSOffState];
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8484 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8485 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8486 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8487 if(style & DW_MIS_ENABLED)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8488 [object setEnabled:YES];
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8489 else if(style & DW_MIS_DISABLED)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8490 [object setEnabled:NO];
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8491 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1313
diff changeset
8492 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8493 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8494
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8495 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8496 * Sets the current focus item for a window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8497 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8498 * handle: Handle to the dialog item to be focused.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8499 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8500 * This is for use after showing the window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8501 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8502 void API dw_window_set_focus(HWND handle)
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8503 {
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8504 id object = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8505
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8506 [[object window] makeFirstResponder:object];
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8507 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8508
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8509 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510 * 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
8511 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 * window: Toplevel window or dialog.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513 * defaultitem: Handle to the dialog item to be default.
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8514 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
8515 * This is for use before showing the window/dialog.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516 */
766
82cde14ec084 Enable recalculating the key view loop (keyboard focus list) automatically.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 763
diff changeset
8517 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
8518 {
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
8519 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
8520 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
8521
872
13debcad9757 Another test fix at reported crash in dw_window_default().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 867
diff changeset
8522 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
8523 {
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
8524 [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
8525 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527
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 * 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
8530 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8531 * 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
8532 * 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
8533 */
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
8534 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
8535 {
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
8536 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
8537 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
8538
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
8539 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
8540 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
8541 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
8542 {
fc6a626a96cc Initial groupbox support. Sizing of the content frame is not quite right yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 768
diff changeset
8543 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
8544
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
8545 [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
8546 }
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
8547 }
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
8548 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
8549 {
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
8550 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
8551 {
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
8552 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
8553 }
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
8554 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
8555 {
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
8556 /* 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
8557 * 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
8558 */
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
8559 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
8560 }
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
8561 [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
8562 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8565 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 * 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
8567 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8568 * handle: Handle to receive mouse input.
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 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
8571 {
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
8572 /* 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
8573 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8574
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8576 * Releases previous mouse capture.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8577 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 void API dw_window_release(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8579 {
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
8580 /* 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
8581 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 * 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
8585 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 * handle: The window handle to destroy.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 * 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
8588 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 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
8590 {
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8591 id object = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8592
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
8593 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
8594 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8595 /* 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
8596 * 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
8597 * 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
8598 */
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8599 NSWindow *window = handle;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8600
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8601 /* 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
8602 if(newparent)
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8603 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8604 object = newparent;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8605
686
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8606 /* 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
8607 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
8608 {
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8609 /* 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
8610 [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
8611 [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
8612 return;
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8613 }
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8614 }
218d676baf7f Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 685
diff changeset
8615 /* 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
8616 [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
8617 [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
8618 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
8621 /* 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
8622 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
8623 * 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
8624 * Returns:
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1050
diff changeset
8625 * 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
8626 */
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8627 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
8628 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8629 /* 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
8630 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
8631 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
8632 DWDialog *dialog;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8633 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
8634
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8635 if(currfont)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8636 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
8637
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8638 if(fontDlg)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8639 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8640 dialog = [fontDlg dialog];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8641 /* 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
8642 if(dialog)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8643 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8644 return NULL;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8645 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8646 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8647 else
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8648 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8649 [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
8650 fontManager = [NSFontManager sharedFontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8651 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
8652 }
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
8653
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8654 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
8655 if(font)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8656 [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
8657 else
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8658 [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
8659 [fontDlg setDialog:dialog];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8660 [fontDlg setFontManager:fontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8661 [fontManager orderFrontFontPanel:fontManager];
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8662
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
8663
1050
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8664 /* 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
8665 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
8666 if(font)
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8667 {
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8668 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
8669 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
8670 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
8671 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8672 return NULL;
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8673 }
48f43c975533 Added dw_font_choose() on the Mac for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1048
diff changeset
8674
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8675 /* Internal function to return a pointer to an item struct
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8676 * with information about the packing information regarding object.
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8677 */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8678 Item *_box_item(id object)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8679 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8680 /* Find the item within the box it is packed into */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8681 if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[DWGroupBox class]] || [object isKindOfClass:[NSControl class]])
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8682 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8683 DWBox *parent = (DWBox *)[object superview];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8684
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8685 /* Some controls are embedded in scrollviews...
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8686 * so get the parent of the scrollview in that case.
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8687 */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8688 if([object isKindOfClass:[NSTableView class]] && [parent isMemberOfClass:[NSClipView class]])
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8689 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8690 object = [parent superview];
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8691 parent = (DWBox *)[object superview];
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8692 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8693
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8694 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]])
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8695 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8696 Box *thisbox = [parent box];
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8697 Item *thisitem = thisbox->items;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8698 int z;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8699
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8700 for(z=0;z<thisbox->count;z++)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8701 {
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8702 if(thisitem[z].hwnd == object)
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8703 return &thisitem[z];
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8704 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8705 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8706 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8707 return NULL;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8708 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8709
650
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 * 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
8712 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8713 * handle: The window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8714 * 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
8715 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8716 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
8717 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
8718 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
8719
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
8720 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
8721 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8722 id object = _text_handle(handle);
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
8723 if([object window])
673
6d0f0dc7ff7c Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
8724 {
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
8725 [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
8726 [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
8727 [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
8728 }
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
8729 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
8730 {
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
8731 [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
8732 }
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
8733 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
8734 {
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
8735 [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
8736 [[object cell] setFont:font];
673
6d0f0dc7ff7c Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
8737 }
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
8738 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
8739 {
d29fb0d5b291 Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 744
diff changeset
8740 DWRender *render = object;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8741
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
8742 [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
8743 }
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8744 else
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8745 return DW_ERROR_UNKNOWN;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8746 /* If we changed the text... */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8747 Item *item = _box_item(handle);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8748
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8749 /* Check to see if any of the sizes need to be recalculated */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8750 if(item && (item->origwidth == -1 || item->origheight == -1))
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8751 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8752 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8753 /* Queue a redraw on the top-level window */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8754 _dw_redraw([object window], TRUE);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8755 }
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8756 return DW_ERROR_NONE;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8757 }
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8758 return DW_ERROR_UNKNOWN;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8759 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8760
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8761 /*
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8762 * Returns the current font for the specified window
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8763 * Parameters:
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8764 * 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
8765 */
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8766 char * API dw_window_get_font(HWND handle)
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8767 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8768 id object = _text_handle(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
8769 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
8770
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
8771 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
8772 {
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
8773 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
8774 }
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
8775 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
8776 {
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
8777 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
8778 }
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
8779 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
8780 {
1041
6a57bf20d8f9 Return displayName property instead of fontName property in dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1040
diff changeset
8781 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
8782 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
8783 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
8784 }
a0aec9a56914 Font and color improvements... including implementing dw_window_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 738
diff changeset
8785 return NULL;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8786 }
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8787
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
8788 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8789 * 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
8790 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8791 * handle: The window handle to destroy.
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 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
8794 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8795 int _locked_by_me = FALSE;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
8796 DW_LOCAL_POOL_IN;
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8797 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
8798 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
8799
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8800 /* Handle destroying a top-level window */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8801 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8802 {
1313
9f12bc79924b Autorelease fixes for Mac allowing the objects to dealloc when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1312
diff changeset
8803 DWWindow *window = handle;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8804 [window close];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8805 }
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8806 /* Handle removing menu items from menus */
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8807 else if([ object isKindOfClass:[NSMenuItem class]])
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8808 {
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8809 NSMenu *menu = [object menu];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8810
1376
52bbb1acce61 Don't release the menu item when destroying it on Mac... causes crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1375
diff changeset
8811 [menu removeItem:object];
1375
611893219ba9 Implemented dw_menu_delete_item() on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1340
diff changeset
8812 }
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
8813 /* Handle destroying a control or box */
1664
4ec0bce77f70 Fix dw_window_destroy() failing on splitbars and possibly other widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
8814 else if([object isKindOfClass:[NSView 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
8815 {
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
8816 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
8817
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
8818 /* 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
8819 * 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
8820 */
1549
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
8821 if(([object isKindOfClass:[NSTableView class]] || [object isMemberOfClass:[DWMLE class]])
ca6be9c48fff Implemented auto-sizing containers on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1543
diff changeset
8822 && [parent isMemberOfClass:[NSClipView class]])
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
8823 {
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
8824 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
8825 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
8826 }
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
8827
1099
d1cea9be1436 Fixed dw_window_destroy() with groupboxes on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1098
diff changeset
8828 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
8829 {
1671
d5f39d32c4da Initial implementation of dw_box_remove() and dw_box_remove_at_index() for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1664
diff changeset
8830 id window = [object window];
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
8831 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
8832 int z, index = -1;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8833 Item *tmpitem = NULL, *thisitem = thisbox->items;
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8834
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8835 if(!thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8836 thisbox->count = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8837
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
8838 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
8839 {
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
8840 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
8841 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
8842 }
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
8843
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
8844 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
8845 {
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
8846 DW_MUTEX_UNLOCK;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
8847 DW_LOCAL_POOL_OUT;
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
8848 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
8849 }
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
8850
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
8851 [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
8852
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8853 if(thisbox->count > 1)
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
8854 {
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8855 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8856
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8857 /* Copy all but the current entry to the new list */
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8858 for(z=0;z<index;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8859 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8860 tmpitem[z] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8861 }
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8862 for(z=index+1;z<thisbox->count;z++)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8863 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8864 tmpitem[z-1] = thisitem[z];
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8865 }
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
8866 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8867
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
8868 thisbox->items = tmpitem;
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8869 if(thisitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8870 free(thisitem);
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8871 if(tmpitem)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8872 thisbox->count--;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8873 else
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
8874 thisbox->count = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8875
1654
3d4066aab4e0 Fixed windows not automatically redrawing when removing items from a layout
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1652
diff changeset
8876 /* Queue a redraw on the top-level window */
3d4066aab4e0 Fixed windows not automatically redrawing when removing items from a layout
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1652
diff changeset
8877 _dw_redraw(window, TRUE);
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
8878 }
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
8879 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
8880 DW_MUTEX_UNLOCK;
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
8881 DW_LOCAL_POOL_OUT;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8882 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8883 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8884
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8885 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8886 * 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
8887 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8888 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8889 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8890 * 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
8891 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8892 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
8893 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8894 id object = _text_handle(handle);
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8895
808
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
8896 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
8897 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8898 id window = object;
808
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
8899 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
8900
808
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
8901 return strdup([ nsstr UTF8String ]);
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
8902 }
c0641a6d4258 Similar fix for dw_window_get_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 807
diff changeset
8903 else if([ object isKindOfClass:[ NSControl class ] ])
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8904 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8905 NSControl *control = object;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8906 NSString *nsstr = [ control stringValue];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
8907
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8908 return strdup([ nsstr UTF8String ]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8909 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8910 return NULL;
650
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
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8913 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8914 * 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
8915 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8916 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8917 * 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
8918 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8919 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
8920 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8921 id object = _text_handle(handle);
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8922
807
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
8923 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ])
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8924 [object setTitle:[ NSString stringWithUTF8String:text ]];
807
f7016a38bedd Fix for dw_window_set_text() on buttons not working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 806
diff changeset
8925 else if([ object isKindOfClass:[ NSControl class ] ])
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8926 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8927 NSControl *control = object;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8928 [control setStringValue:[ NSString stringWithUTF8String:text ]];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8929 }
953
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
8930 else if([object isMemberOfClass:[DWGroupBox class]])
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
8931 {
1772
5e16351b01d2 Experimental change to use NSBox to draw border of status text widgets on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1771
diff changeset
8932 DWGroupBox *groupbox = object;
953
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
8933 [groupbox setTitle:[NSString stringWithUTF8String:text]];
2dfc06afc7d3 Support dw_window_set_text() for groupboxes
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 952
diff changeset
8934 }
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8935 else
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8936 return;
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8937 /* If we changed the text... */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8938 Item *item = _box_item(handle);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8939
1410
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8940 /* Check to see if any of the sizes need to be recalculated */
c607fd86e5c2 Initial code on the Mac to automatically calculate widget required sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
8941 if(item && (item->origwidth == -1 || item->origheight == -1))
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8942 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8943 int newwidth, newheight;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8944
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8945 _control_size(handle, &newwidth, &newheight);
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
8946
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8947 /* Only update the item and redraw the window if it changed */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8948 if((item->origwidth == -1 && item->width != newwidth) ||
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8949 (item->origheight == -1 && item->height != newheight))
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8950 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8951 if(item->origwidth == -1)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8952 item->width = newwidth;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8953 if(item->origheight == -1)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8954 item->height = newheight;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8955 /* Queue a redraw on the top-level window */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8956 _dw_redraw([object window], TRUE);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1791
diff changeset
8957 }
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
8958 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8959 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8960
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8961 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8962 * Sets the text used for a given window's floating bubble help.
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8963 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8964 * handle: Handle to the window (widget).
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8965 * bubbletext: The text in the floating bubble tooltip.
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8966 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8967 void API dw_window_set_tooltip(HWND handle, char *bubbletext)
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8968 {
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8969 id object = handle;
1400
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1396
diff changeset
8970 if(bubbletext && *bubbletext)
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1396
diff changeset
8971 [object setToolTip:[NSString stringWithUTF8String:bubbletext]];
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1396
diff changeset
8972 else
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1396
diff changeset
8973 [object setToolTip:nil];
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8974 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8975
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1385
diff changeset
8976 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8977 * Disables given window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8978 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8979 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8980 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8981 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
8982 {
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
8983 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
8984
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
8985 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
8986 {
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
8987 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
8988 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
8989 }
1277
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
8990 if([object isKindOfClass:[NSControl class]] || [object isKindOfClass:[NSMenuItem class]])
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
8991 {
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
8992 [object setEnabled:NO];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
8993 }
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
8994 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
8995 {
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
8996 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
8997
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
8998 [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
8999 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9000 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9001
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9002 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9003 * Enables given window (widget).
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9004 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9005 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9006 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9007 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
9008 {
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
9009 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
9010
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
9011 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
9012 {
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
9013 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
9014 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
9015 }
1277
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9016 if([object isKindOfClass:[NSControl class]] || [object isKindOfClass:[NSMenuItem class]])
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9017 {
107e38a29eeb Allow dw_window_enable/disable() to work on menu items on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9018 [object setEnabled:YES];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9019 }
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
9020 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
9021 {
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
9022 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
9023
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
9024 [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
9025 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9026 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9027
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9028 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9029 * 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
9030 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9031 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9032 * 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
9033 * (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
9034 * 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
9035 * 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
9036 * 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
9037 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
9038 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
9039 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9040 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9041 if([ object isKindOfClass:[ NSImageView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9042 {
1719
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9043 if(data)
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9044 {
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9045 DW_LOCAL_POOL_IN;
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9046 NSImageView *iv = handle;
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9047 NSData *thisdata = [NSData dataWithBytes:data length:len];
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9048 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9049
1719
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9050 if(pixmap)
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9051 {
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9052 [iv setImage:pixmap];
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9053 }
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9054 [pixmap release];
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9055 /* If we changed the text... */
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9056 Item *item = _box_item(handle);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9057
1719
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9058 /* Check to see if any of the sizes need to be recalculated */
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9059 if(item && (item->origwidth == -1 || item->origheight == -1))
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9060 {
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9061 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
1719
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9062 /* Queue a redraw on the top-level window */
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9063 _dw_redraw([iv window], TRUE);
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9064 }
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9065 DW_LOCAL_POOL_OUT;
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9066 }
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9067 else
032c3388dda6 Fix dw_window_set_bitmap_from_data() not using the resource ID if data is NULL.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1713
diff changeset
9068 dw_window_set_bitmap(handle, cid, NULL);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9069 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9070 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9071
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9072 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9073 * 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
9074 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9075 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9076 * 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
9077 * (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
9078 * 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
9079 * 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
9080 * 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
9081 */
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
9082 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
9083 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9084 NSObject *object = handle;
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
9085 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9086
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9087 if([ object isKindOfClass:[ NSImageView class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9088 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9089 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
9090 NSImage *bitmap = nil;
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
9091
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
9092 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
9093 {
1557
030e9bddc1c9 Fixed some potential Objective-C memory leaks on Mac reported by XCode 4.2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
9094 bitmap = [[[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]] autorelease];
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
9095 }
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
9096 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
9097 {
1713
c836c6c33d8e Create an internal _dw_icon_load() which does not resize the image on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1712
diff changeset
9098 bitmap = _dw_icon_load(resid);
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
9099 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9100
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
9101 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
9102 {
48f8efba898f Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 674
diff changeset
9103 [iv setImage:bitmap];
1421
63d253a2cdd9 Added bitmap autosizing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1420
diff changeset
9104 /* Queue a redraw on the top-level window */
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1421
diff changeset
9105 _dw_redraw([iv window], TRUE);
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
9106 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9107 }
1580
a51397ea24bf Added local auto-release macros on Mac to allow us to prevent leaks
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1574
diff changeset
9108 DW_LOCAL_POOL_OUT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9109 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9110
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 * 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
9113 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9114 * handle: Handle to the window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9115 * 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
9116 */
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
9117 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
9118 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9119 /* 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
9120 }
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9123 * 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
9124 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9125 * handle: Handle to the parent window.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9126 * id: Integer ID of the child.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9127 */
685
314a12dccd20 Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 684
diff changeset
9128 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
9129 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9130 NSObject *object = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9131 NSView *view = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9132 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9133 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9134 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9135 view = [window contentView];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9136 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9137 return [view viewWithTag:cid];
650
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 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 * 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
9142 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 * handle: The window handle to minimize.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9144 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 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
9146 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9147 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9148 [window miniaturize:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9149 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9151
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9152 /* 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
9153 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9154 * 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
9155 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9156 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
9157 {
1101
d7eafaa054ab Added support for dw_window_redraw() causing splitbar panes to redraw without
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1100
diff changeset
9158 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
9159 [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
9160 [[window contentView] showWindow];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9161 [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
9162 [window setRedraw:NO];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9163 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9164
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9165 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9166 * Makes the window topmost.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9167 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9168 * 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
9169 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9170 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
9171 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9172 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9173 [window orderFront:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9174 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9175 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9176
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9177 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9178 * Makes the window bottommost.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9179 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9180 * 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
9181 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9182 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
9183 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9184 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9185 [window orderBack:nil];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9186 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9187 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9188
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9189 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9190 * 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
9191 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9192 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9193 * width: New width in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9194 * height: New height in pixels.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9195 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9196 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
9197 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9198 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9199 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9200 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9201
1494
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9202 if([ object isMemberOfClass:[ DWWindow class ] ])
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9203 {
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9204 DWWindow *window = handle;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9205 Box *thisbox;
1478
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9206 NSRect content, frame = NSMakeRect(0, 0, width, height);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9207
1478
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9208 /* Convert the external frame size to internal content size */
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9209 content = [NSWindow contentRectForFrameRect:frame styleMask:[window styleMask]];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9210
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9211 /*
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9212 * The following is an attempt to dynamically size a window based on the size of its
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9213 * children before realization. Only applicable when width or height is less than one.
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9214 */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9215 if((width < 1 || height < 1) && (thisbox = [[window contentView] box]))
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9216 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9217 int depth = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9218
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9219 /* Calculate space requirements */
1446
0d4fdf646caf Fix clang integer conversion warning on 64bit Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
9220 _resize_box(thisbox, &depth, (int)width, (int)height, 1);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9221
1531
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1530
diff changeset
9222 /* Update components that need auto-sizing */
1478
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9223 if(width < 1) content.size.width = thisbox->minwidth;
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9224 if(height < 1) content.size.height = thisbox->minheight;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9225 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9226
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1437
diff changeset
9227 /* Finally set the size */
1478
7216f4301364 Fix mixing frame and content sizes on the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1474
diff changeset
9228 [window setContentSize:content.size];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9229 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9230 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9231 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9232
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9233 /*
1429
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9234 * Gets the size the system thinks the widget should be.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9235 * Parameters:
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9236 * handle: Window handle of the item to be back.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9237 * width: Width in pixels of the item or NULL if not needed.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9238 * height: Height in pixels of the item or NULL if not needed.
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9239 */
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9240 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9241 {
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9242 id object = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9243
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9244 if([object isMemberOfClass:[DWWindow class]])
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9245 {
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9246 Box *thisbox;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9247
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9248 if((thisbox = [[object contentView] box]))
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9249 {
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9250 int depth = 0;
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9251 NSRect frame;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9252
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9253 /* Calculate space requirements */
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9254 _resize_box(thisbox, &depth, 0, 0, 1);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9255
1531
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1530
diff changeset
9256 /* Figure out the border size */
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9257 frame = [NSWindow frameRectForContentRect:NSMakeRect(0, 0, thisbox->minwidth, thisbox->minheight) styleMask:[object styleMask]];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9258
1531
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1530
diff changeset
9259 /* Return what was requested */
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9260 if(width) *width = frame.size.width;
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9261 if(height) *height = frame.size.height;
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9262 }
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9263 }
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9264 else if([object isMemberOfClass:[DWBox class]])
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9265 {
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9266 Box *thisbox;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9267
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9268 if((thisbox = [object box]))
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9269 {
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9270 int depth = 0;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9271
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9272 /* Calculate space requirements */
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9273 _resize_box(thisbox, &depth, 0, 0, 1);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9274
1531
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1530
diff changeset
9275 /* Return what was requested */
1530
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9276 if(width) *width = thisbox->minwidth;
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9277 if(height) *height = thisbox->minheight;
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9278 }
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9279 }
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9280 else
eecfceaf581f On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1529
diff changeset
9281 _control_size(handle, width, height);
1429
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9282 }
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9283
fbaec6e5df63 Added dw_window_get_preferred_size() which attempts to determine the size the system wants for the widget. This is useful when creating nice looking layouts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
9284 /*
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9285 * Sets the gravity of a given window (widget).
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9286 * Gravity controls which corner of the screen and window the position is relative to.
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9287 * Parameters:
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9288 * handle: Window (widget) handle.
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9289 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9290 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9291 */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9292 void API dw_window_set_gravity(HWND handle, int horz, int vert)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9293 {
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9294 dw_window_set_data(handle, "_dw_grav_horz", DW_INT_TO_POINTER(horz));
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9295 dw_window_set_data(handle, "_dw_grav_vert", DW_INT_TO_POINTER(vert));
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9296 }
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9297
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9298 /* Convert the coordinates based on gravity */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9299 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9300 {
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9301 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz"));
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9302 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert"));
1513
def1ca619ba2 Use the screen of the window when possible on Mac instead of the main screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1502
diff changeset
9303 id object = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9304
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9305 /* Do any gravity calculations */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9306 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9307 {
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9308 long newx = *x, newy = *y;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9309
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9310 /* Handle horizontal center gravity */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9311 if((horz & 0xf) == DW_GRAV_CENTER)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9312 newx += ((dw_screen_width() / 2) - (width / 2));
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9313 /* Handle right gravity */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9314 else if((horz & 0xf) == DW_GRAV_RIGHT)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9315 newx = dw_screen_width() - width - *x;
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9316 /* Handle vertical center gravity */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9317 if((vert & 0xf) == DW_GRAV_CENTER)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9318 newy += ((dw_screen_height() / 2) - (height / 2));
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9319 else if((vert & 0xf) == DW_GRAV_TOP)
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9320 newy = dw_screen_height() - height - *y;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9321
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9322 /* Save the new values */
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9323 *x = newx;
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9324 *y = newy;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9325 }
1492
1608c2a9c2b8 Initial attempt at gravity obstacles on Mac.... doesn't work was trying to debug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1490
diff changeset
9326 /* Adjust the values to avoid Dock/Menubar if requested */
1494
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9327 if((horz | vert) & DW_GRAV_OBSTACLES)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9328 {
1513
def1ca619ba2 Use the screen of the window when possible on Mac instead of the main screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1502
diff changeset
9329 NSRect visiblerect = [[object screen] visibleFrame];
def1ca619ba2 Use the screen of the window when possible on Mac instead of the main screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1502
diff changeset
9330 NSRect totalrect = [[object screen] frame];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9331
1494
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9332 if(horz & DW_GRAV_OBSTACLES)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9333 {
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9334 if((horz & 0xf) == DW_GRAV_LEFT)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9335 *x += visiblerect.origin.x;
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9336 else if((horz & 0xf) == DW_GRAV_RIGHT)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9337 *x -= (totalrect.origin.x + totalrect.size.width) - (visiblerect.origin.x + visiblerect.size.width);
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9338 }
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9339 if(vert & DW_GRAV_OBSTACLES)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9340 {
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9341 if((vert & 0xf) == DW_GRAV_BOTTOM)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9342 *y += visiblerect.origin.y;
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9343 else if((vert & 0xf) == DW_GRAV_TOP)
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9344 *y -= (totalrect.origin.y + totalrect.size.height) - (visiblerect.origin.y + visiblerect.size.height);
cf960e266444 Fixes for gravity obstacles on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1492
diff changeset
9345 }
1492
1608c2a9c2b8 Initial attempt at gravity obstacles on Mac.... doesn't work was trying to debug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1490
diff changeset
9346 }
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9347 }
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9348
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9349 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9350 * 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
9351 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9352 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9353 * 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
9354 * 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
9355 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356 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
9357 {
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9358 int _locked_by_me = FALSE;
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9359 DW_MUTEX_LOCK;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9360 NSObject *object = handle;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9361
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
9362 if([ object isMemberOfClass:[ DWWindow class ] ])
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
9363 {
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
9364 DWWindow *window = handle;
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9365 NSPoint point;
1498
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9366 NSSize size = [[window contentView] frame].size;
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9367
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9368 /* Can't position an unsized window, so attempt to auto-size */
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9369 if(size.width <= 1 || size.height <= 1)
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9370 {
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9371 /* Determine the contents size */
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9372 dw_window_set_size(handle, 0, 0);
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9373 }
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9374
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1497
diff changeset
9375 size = [window frame].size;
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9376 _handle_gravity(handle, &x, &y, (unsigned long)size.width, (unsigned long)size.height);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9377
1474
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9378 point.x = x;
cd3d7e341467 Initial implementation of dw_window_set_gravity() on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1457
diff changeset
9379 point.y = y;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9380
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9381 [window setFrameOrigin:point];
1497
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
9382 /* Position set manually... don't auto-position */
99a53823079f On Mac lets just use the shown flag and not worry about the actual window position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1494
diff changeset
9383 [window setShown:YES];
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9384 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
9385 DW_MUTEX_UNLOCK;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9386 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9387
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 * 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
9390 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9391 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9392 * 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
9393 * 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
9394 * width: Width of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 * height: Height of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9396 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 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
9398 {
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
9399 dw_window_set_size(handle, width, height);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9400 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
9401 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9402
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9403 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9404 * 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
9405 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 * handle: Window (widget) handle.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9407 * 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
9408 * 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
9409 * width: Width of the widget.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9410 * height: Height of the widget.
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 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
9413 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9414 NSObject *object = handle;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9415
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9416 if([ object isKindOfClass:[ NSWindow class ] ])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9417 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9418 NSWindow *window = handle;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9419 NSRect rect = [window frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9420 if(x)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9421 *x = rect.origin.x;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9422 if(y)
1513
def1ca619ba2 Use the screen of the window when possible on Mac instead of the main screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1502
diff changeset
9423 *y = [[window screen] 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
9424 if(width)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9425 *width = rect.size.width;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9426 if(height)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9427 *height = rect.size.height;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9428 return;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9429 }
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
9430 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
9431 {
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
9432 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
9433 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
9434 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
9435 *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
9436 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
9437 *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
9438 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
9439 *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
9440 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
9441 *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
9442 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
9443 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9444 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9445
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9446 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9447 * Returns the width of the screen.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9448 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9449 int API dw_screen_width(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9450 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9451 NSRect screenRect = [[NSScreen mainScreen] frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9452 return screenRect.size.width;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9453 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9454
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9455 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9456 * Returns the height of the screen.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9457 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9458 int API dw_screen_height(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9459 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9460 NSRect screenRect = [[NSScreen mainScreen] frame];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9461 return screenRect.size.height;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9462 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9463
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9464 /* 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
9465 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
9466 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9467 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9468 return NSBitsPerPixelFromDepth(screenDepth);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9469 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9470
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9471 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9472 * 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
9473 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9474 * env: Pointer to a DWEnv struct.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9475 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9476 void dw_environment_query(DWEnv *env)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9477 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9478 struct utsname name;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9479
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9480 uname(&name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9481 strcpy(env->osName, "MacOS");
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9482
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9483 strcpy(env->buildDate, __DATE__);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9484 strcpy(env->buildTime, __TIME__);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9485 env->DWMajorVersion = DW_MAJOR_VERSION;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9486 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
9487 #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
9488 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
9489 #else
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9490 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
9491 #endif
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9492
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
9493 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
9494 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
9495 env->MajorBuild = DWOSBuild;
809
1ef0f4c03c14 MinorBuild was being left uninitialized.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 808
diff changeset
9496 env->MinorBuild = 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9497 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9498
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9499 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9500 * Emits a beep.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9501 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9502 * freq: Frequency.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9503 * dur: Duration.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9504 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9505 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
9506 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9507 NSBeep();
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9508 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9509
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9510 /* 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
9511 * anything you have drawn is visible.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9512 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9513 void API dw_flush(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9514 {
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
9515 /* 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
9516 [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
9517 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9518
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9519 /* 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
9520 * 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
9521 * dw_window_get_data().
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9522 */
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9523 UserData *_find_userdata(UserData **root, char *varname)
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9524 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9525 UserData *tmp = *root;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9526
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9527 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9528 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9529 if(strcasecmp(tmp->varname, varname) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9530 return tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9531 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9532 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9533 return NULL;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9534 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9535
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9536 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
9537 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9538 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
9539
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9540 if(new)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9541 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9542 new->data = data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9543 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9544 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9545 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9546 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9547 new = malloc(sizeof(UserData));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9548 if(new)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9549 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9550 new->varname = strdup(varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9551 new->data = data;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9552
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9553 new->next = NULL;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9554
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9555 if (!*root)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9556 *root = new;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9557 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9558 {
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1302
diff changeset
9559 UserData *prev = *root, *tmp = prev->next;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
9560
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9561 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9562 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9563 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9564 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9565 }
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1302
diff changeset
9566 prev->next = new;
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9567 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9568 return TRUE;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9569 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9570 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9571 return FALSE;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9572 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9573
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9574 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
9575 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9576 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
9577
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9578 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9579 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9580 if(all || strcasecmp(tmp->varname, varname) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9581 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9582 if(!prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9583 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9584 *root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9585 free(tmp->varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9586 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9587 if(!all)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9588 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9589 tmp = *root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9590 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9591 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9592 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9593 /* If all is true we should
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9594 * never get here.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9595 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9596 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9597 free(tmp->varname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9598 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9599 return 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9600 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9601 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9602 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9603 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9604 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9605 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9606 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9607 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9608 return 0;
651
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9609 }
270580896dac Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 650
diff changeset
9610
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9612 * 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
9613 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 * 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
9615 * 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
9616 * 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
9617 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9618 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
9619 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9620 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
9621 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
9622 {
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
9623 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
9624 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
9625 }
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
9626 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
9627 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
9628 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
9629 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
9630 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9631 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
9632
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9633 if(!blah)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9634 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9635 if(!dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9636 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9637
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9638 blah = calloc(1, sizeof(WindowData));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9639 [object setUserdata:blah];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9640 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9641
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9642 if(data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9643 _new_userdata(&(blah->root), dataname, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9644 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9645 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9646 if(dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9647 _remove_userdata(&(blah->root), dataname, FALSE);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9648 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9649 _remove_userdata(&(blah->root), NULL, TRUE);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9650 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9651 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9652
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9653 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9654 * 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
9655 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9656 * 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
9657 * 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
9658 * 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
9659 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9660 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
9661 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9662 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
9663 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
9664 {
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
9665 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
9666 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
9667 }
5fe12469c1fb Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 680
diff changeset
9668 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
9669 {
9861d264925d MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 675
diff changeset
9670 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
9671 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
9672 }
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9673 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
9674
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9675 if(blah && blah->root && dataname)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9676 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9677 UserData *ud = _find_userdata(&(blah->root), dataname);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9678 if(ud)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9679 return ud->data;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9680 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9681 return NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9682 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9683
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
9684 #define DW_TIMER_MAX 64
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
9685 NSTimer *DWTimers[DW_TIMER_MAX];
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
9686
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9687 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9688 * 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
9689 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9690 * interval: Milliseconds to delay between calls.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9691 * 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
9692 * 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
9693 * Returns:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9694 * 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
9695 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9696 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
9697 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9698 int z;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9699
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9700 for(z=0;z<DW_TIMER_MAX;z++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9701 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9702 if(!DWTimers[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9703 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9704 break;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9705 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9706 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9707
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9708 if(sigfunc && !DWTimers[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9709 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9710 NSTimeInterval seconds = (double)interval / 1000.0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9711 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
9712 _new_signal(0, thistimer, z+1, sigfunc, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9713 return z+1;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9714 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9715 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9716 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9717
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9718 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9719 * Removes timer callback.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9720 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9721 * 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
9722 */
657
f31a47b055f8 Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 656
diff changeset
9723 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
9724 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9725 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9726 NSTimer *thistimer;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9727
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9728 /* 0 is an invalid timer ID */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9729 if(timerid < 1 || !DWTimers[timerid-1])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9730 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9731
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9732 thistimer = DWTimers[timerid-1];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9733 DWTimers[timerid-1] = nil;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9734
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9735 [thistimer invalidate];
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9736
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9737 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9738 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9739 if(tmp->id == timerid && tmp->window == thistimer)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9740 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9741 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9742 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9743 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9744 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9745 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9746 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9747 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9748 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9749 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9750 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9751 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9752 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9753 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9754 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9755 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9756 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9757 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9758 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9759 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9760 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9761
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9762 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9763 * 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
9764 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9765 * 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
9766 * 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
9767 * 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
9768 * 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
9769 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9770 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
9771 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9772 ULONG message = 0, msgid = 0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9773
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9774 if(window && signame && sigfunc)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9775 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9776 if((message = _findsigmessage(signame)) != 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9777 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9778 _new_signal(message, window, (int)msgid, sigfunc, data);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9779 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9780 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9781 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9782
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9783 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9784 * 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
9785 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9786 * 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
9787 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9788 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
9789 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9790 SignalHandler *prev = NULL, *tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9791 ULONG message;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9792
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9793 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9794 return;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
9795
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9796 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9797 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9798 if(tmp->window == window && tmp->message == message)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9799 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9800 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9801 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9802 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9803 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9804 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9805 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9806 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9807 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9808 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9809 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9810 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9811 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9812 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9813 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9814 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9815 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9816 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9817 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9818 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9819 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9820
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9821 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9822 * 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
9823 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9824 * 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
9825 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9826 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
9827 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9828 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
9829
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9830 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9831 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9832 if(tmp->window == window)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9833 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9834 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9835 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9836 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9837 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9838 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9839 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9840 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9841 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9842 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9843 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9844 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9845 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9846 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9847 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9848 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9849 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9850 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9851 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9852 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9853 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9854
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9855 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9856 * 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
9857 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9858 * 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
9859 * 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
9860 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 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
9862 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9863 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
9864
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9865 while(tmp)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9866 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9867 if(tmp->window == window && tmp->data == data)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9868 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9869 if(prev)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9870 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9871 prev->next = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9872 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9873 tmp = prev->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9874 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9875 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9876 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9877 Root = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9878 free(tmp);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9879 tmp = Root;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9880 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9881 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9882 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9883 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9884 prev = tmp;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9885 tmp = tmp->next;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9886 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
9887 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 void _my_strlwr(char *buf)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 {
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
9892 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
9893
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9894 for(z=0;z<len;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9896 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
9897 buf[z] -= 'A' - 'a';
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9898 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9899 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9900
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9901 /* 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
9902 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9903 * 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
9904 * handle: Pointer to a module handle,
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9905 * 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
9906 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9907 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
9908 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9909 int len;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9910 char *newname;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
9911 char errorbuf[1025];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9912
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9914 if(!handle)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
9917 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
9918 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920 /* Lenth + "lib" + ".dylib" + NULL */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921 newname = malloc(len + 10);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 if(!newname)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926 sprintf(newname, "lib%s.dylib", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 _my_strlwr(newname);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9929 *handle = dlopen(newname, RTLD_NOW);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 if(*handle == NULL)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9931 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932 strncpy(errorbuf, dlerror(), 1024);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9933 printf("%s\n", errorbuf);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9934 sprintf(newname, "lib%s.dylib", name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9935 *handle = dlopen(newname, RTLD_NOW);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9936 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9937
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9938 free(newname);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9939
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9940 return (NULL == *handle) ? -1 : 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9941 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9942
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943 /* 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
9944 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9945 * 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
9946 * 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
9947 * 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
9948 * the address.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9949 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9950 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
9951 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9952 if(!func || !name)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9953 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9954
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9955 if(strlen(name) == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9956 return -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9957
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9958 *func = (void*)dlsym(handle, name);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9959 return (NULL == *func);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9960 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9961
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9962 /* Frees the shared library previously opened.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9963 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9964 * 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
9965 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9966 int dw_module_close(HMOD handle)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9967 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9968 if(handle)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9969 return dlclose(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9971 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 * 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
9975 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 HMTX dw_mutex_new(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9977 {
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
9978 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
9979
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
9980 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
9981 return mutex;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9982 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9983
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9984 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9985 * 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
9986 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9987 * 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
9988 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9989 void dw_mutex_close(HMTX mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9990 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9991 if(mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9992 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9993 pthread_mutex_destroy(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9994 free(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9995 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9996 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9997
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 * 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
10000 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 * 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
10002 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 void dw_mutex_lock(HMTX mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
10005 /* 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
10006 * 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
10007 * 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
10008 * 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
10009 */
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
10010 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
10011 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
10012 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
10013 {
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
10014 /* 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
10015 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
10016 {
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
10017 /* 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
10018 }
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
10019 }
691
578bbfd8c904 Added initial thread synchronization code to stop the main loop when doing thread unsafe things.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 690
diff changeset
10020 }
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
10021 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
10022 {
693
2f21ee9d7c7b Experimental change for locking on the main thread... will be committing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 692
diff changeset
10023 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
10024 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10025 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10026
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10027 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10028 * 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
10029 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10030 * 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
10031 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10032 * 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
10033 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10034 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
10035 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10036 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
10037 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
10038 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
10039 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10040
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10041 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10042 * Reliquishes the access to the semaphore.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10043 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10044 * 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
10045 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10046 void dw_mutex_unlock(HMTX mutex)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10047 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10048 pthread_mutex_unlock(mutex);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10049 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10050
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10051 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10052 * 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
10053 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10054 HEV dw_event_new(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10055 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10056 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
10057
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10058 if(!eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10059 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10060
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10061 /* 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
10062 * 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
10063 * 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
10064 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10065 pthread_mutex_init (&(eve->mutex), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10066 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10067 pthread_cond_init (&(eve->event), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10068
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10069 pthread_mutex_unlock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10070 eve->alive = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10071 eve->posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10072
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10073 return eve;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10074 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10075
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10076 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10077 * 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
10078 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10079 * 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
10080 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10081 int dw_event_reset (HEV eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10082 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10083 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
10084 return DW_ERROR_NON_INIT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10085
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10086 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10087 pthread_cond_broadcast (&(eve->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10088 pthread_cond_init (&(eve->event), NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10089 eve->posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10090 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
10091 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10092 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10093
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10094 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10095 * 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
10096 * 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
10097 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10098 * 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
10099 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10100 int dw_event_post (HEV eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10101 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10102 if(!eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10103 return FALSE;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10104
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10105 pthread_mutex_lock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10106 pthread_cond_broadcast (&(eve->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10107 eve->posted = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10108 pthread_mutex_unlock (&(eve->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10109 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10110 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10111
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10112 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10113 * 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
10114 * 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
10115 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10116 * 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
10117 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10118 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
10119 {
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
10120 int rc;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10121
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
10122 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
10123 return DW_ERROR_NON_INIT;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10124
1202
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
10125 pthread_mutex_lock (&(eve->mutex));
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10126
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
10127 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
10128 {
5c1a01c6384d Think we need to check the posted state inside the mutex...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1201
diff changeset
10129 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
10130 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
10131 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10132
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
10133 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
10134 {
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
10135 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
10136 struct timespec timeo;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10137
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
10138 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
10139 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
10140 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
10141 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
10142 }
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
10143 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
10144 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
10145 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
10146 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
10147 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
10148 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
10149 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
10150 return DW_ERROR_GENERAL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10151 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10152
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10153 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10154 * 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
10155 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10156 * 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
10157 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10158 int dw_event_close(HEV *eve)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10159 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10160 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
10161 return DW_ERROR_NON_INIT;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10162
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10163 pthread_mutex_lock (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10164 pthread_cond_destroy (&((*eve)->event));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10165 pthread_mutex_unlock (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10166 pthread_mutex_destroy (&((*eve)->mutex));
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10167 free(*eve);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10168 *eve = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10169
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
10170 return DW_ERROR_NONE;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10171 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10172
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10173 struct _seminfo {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10174 int fd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10175 int waiting;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10176 };
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10177
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10178 static void _handle_sem(int *tmpsock)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10179 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10180 fd_set rd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10181 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
10182 int listenfd = tmpsock[0];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10183 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
10184 char command;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10185 sigset_t mask;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10186
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10187 sigfillset(&mask); /* Mask all allowed signals */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10188 pthread_sigmask(SIG_BLOCK, &mask, NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10189
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10190 /* problems */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10191 if(tmpsock[1] == -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10192 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10193 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10194 return;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10195 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10196
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10197 array[0].fd = tmpsock[1];
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10198 array[0].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10199
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10200 /* 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
10201 free(tmpsock);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10202
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10203 while(1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10204 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10205 FD_ZERO(&rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10206 FD_SET(listenfd, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10207
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10208 maxfd = listenfd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10209
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10210 /* 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
10211 for(z=0;z<connectcount;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10212 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10213 if(array[z].fd > maxfd)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10214 maxfd = array[z].fd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10215
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10216 FD_SET(array[z].fd, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10217 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10218
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10219 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
10220 return;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10221
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10222 if(FD_ISSET(listenfd, &rd))
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10223 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10224 struct _seminfo *newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10225 int newfd = accept(listenfd, 0, 0);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10226
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10227 if(newfd > -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10228 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10229 /* Add new connections to the set */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10230 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
10231 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
10232
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10233 newarray[connectcount].fd = newfd;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10234 newarray[connectcount].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10235
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10236 connectcount++;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10237
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10238 /* Replace old array with new one */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10239 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10240 array = newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10241 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10242 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10243
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10244 /* 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
10245 for(z=0;z<connectcount;z++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10246 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10247 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
10248 {
1110
404b639f096b Minor typecast fixes for warnings reported by clang on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1102
diff changeset
10249 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
10250 {
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10251 struct _seminfo *newarray = NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10252
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10253 /* Remove this connection from the set */
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10254 if(connectcount > 1)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10255 {
1764
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10256 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1));
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10257 if(!z)
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10258 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1));
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10259 else
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10260 {
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10261 memcpy(newarray, array, sizeof(struct _seminfo)*z);
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10262 if(z!=(connectcount-1))
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10263 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1));
5ffeea4a2a4b Fixed a memory leak in the Mac box code, items were not being freed when destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1748
diff changeset
10264 }
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10265 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10266 connectcount--;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10267
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10268 /* Replace old array with new one */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10269 free(array);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10270 array = newarray;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10271 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10272 else if(bytesread == 1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10273 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10274 switch(command)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10275 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10276 case 0:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10277 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10278 /* Reset */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10279 posted = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10280 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10281 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10282 case 1:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10283 /* Post */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10284 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10285 int s;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10286 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10287
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10288 posted = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10289
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10290 for(s=0;s<connectcount;s++)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10291 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10292 /* The semaphore has been posted so
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10293 * 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
10294 * continue.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10295 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10296 if(array[s].waiting)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10297 write(array[s].fd, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10298 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10299 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10300 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10301 case 2:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10302 /* Wait */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10303 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10304 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10305
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10306 array[z].waiting = 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10307
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10308 /* If we are posted exit immeditately */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10309 if(posted)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10310 write(array[z].fd, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10311 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10312 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10313 case 3:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10314 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10315 /* Done Waiting */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10316 array[z].waiting = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10317 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318 break;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10320 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10321 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10322 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10323 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10324 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10325
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10326 /* 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
10327 /* 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
10328 * opened from other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10329 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10330 * 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
10331 * 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
10332 * by other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10333 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10334 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
10335 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10336 struct sockaddr_un un;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10337 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10338 HEV eve;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10339 DWTID dwthread;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10340
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10341 if(!tmpsock)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10342 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10343
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10344 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10345
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10346 if(!eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10347 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10348 free(tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10349 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10350 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10351
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10352 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10353 ev = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10354 memset(&un, 0, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10355 un.sun_family=AF_UNIX;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10356 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10357 strcpy(un.sun_path, "/tmp/.dw/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10358 strcat(un.sun_path, name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10359
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10360 /* just to be safe, this should be changed
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10361 * to support multiple instances.
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10362 */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10363 remove(un.sun_path);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10364
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10365 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10366 listen(tmpsock[0], 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10367 connect(ev, (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10368 tmpsock[1] = accept(tmpsock[0], 0, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10369
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10370 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10371 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10372 if(tmpsock[0] > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10373 close(tmpsock[0]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10374 if(tmpsock[1] > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10375 close(tmpsock[1]);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10376 if(ev > -1)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10377 close(ev);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10378 free(tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10379 free(eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10380 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10381 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10382
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10383 /* Create a thread to handle this event semaphore */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10384 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10385 eve->alive = ev;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10386 return eve;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10387 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10388
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10389 /* 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
10390 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10391 * 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
10392 * 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
10393 * by other processes.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10394 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10395 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
10396 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10397 struct sockaddr_un un;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10398 HEV eve;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10399 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10400 if(ev < 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10401 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10402
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10403 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10404
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10405 if(!eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10406 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10407 close(ev);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10408 return NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10409 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10410
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10411 un.sun_family=AF_UNIX;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10412 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10413 strcpy(un.sun_path, "/tmp/.dw/");
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10414 strcat(un.sun_path, name);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10415 connect(ev, (struct sockaddr *)&un, sizeof(un));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10416 eve->alive = ev;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10417 return eve;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10418 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10419
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10420 /* 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
10421 * on this semaphore will block.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10422 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10423 * 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
10424 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10425 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10426 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
10427 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10428 /* signal reset */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10429 char tmp = (char)0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10430
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10431 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10432 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10433
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10434 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
10435 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10436 return 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10437 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10438
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10439 /* 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
10440 * 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
10441 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10442 * 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
10443 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10444 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10445 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
10446 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10447
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10448 /* signal post */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10449 char tmp = (char)1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10450
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10451 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10452 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10453
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10454 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
10455 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10456 return 1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10457 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10458
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10459 /* 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
10460 * 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
10461 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10462 * 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
10463 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10464 * 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
10465 * or -1 if indefinite.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 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
10468 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 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
10470 struct timeval tv, *useme = NULL;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471 int retval = 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10472 char tmp;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10473
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10474 if(!eve || eve->alive < 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10475 return DW_ERROR_NON_INIT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10476
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10477 /* 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
10478 if(timeout != -1)
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10479 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10480 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
10481 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
10482
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10483 useme = &tv;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10484 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10485
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10486 FD_ZERO(&rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10487 FD_SET(eve->alive, &rd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10488
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10489 /* Signal wait */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10490 tmp = (char)2;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10491 write(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10492
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10493 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
10494
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10495 /* Signal done waiting. */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10496 tmp = (char)3;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10497 write(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10498
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10499 if(retval == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10500 return DW_ERROR_TIMEOUT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10501 else if(retval == -1)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10502 return DW_ERROR_INTERRUPT;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10503
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10504 /* 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
10505 * we don't loop endlessly. :)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10506 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10507 read(eve->alive, &tmp, 1);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10508 return 0;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10509 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10510
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10511 /* 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
10512 * 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
10513 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10514 * 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
10515 * an open or create call.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10516 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10517 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
10518 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10519 /* Finally close the domain socket,
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10520 * cleanup will continue in _handle_sem.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10521 */
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10522 if(eve)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10523 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10524 close(eve->alive);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10525 free(eve);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10526 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10527 return 0;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10528 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10529
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10530 /* 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
10531 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
10532 {
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10533 #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
10534 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
10535 [pool drain];
698
e19f69a78f21 Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 697
diff changeset
10536 pool = [[NSAutoreleasePool alloc] init];
e19f69a78f21 Fix for pool being removed and not just drained.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 697
diff changeset
10537 pthread_setspecific(_dw_pool_key, pool);
731
6a589a1a42b0 Add dw_window_get_font()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 730
diff changeset
10538 #endif
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10539 }
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10540
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10541 /*
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10542 * Setup thread independent pools.
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10543 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10544 void _dwthreadstart(void *data)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10545 {
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
10546 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
10547 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
10548 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
10549
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
10550 /* 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
10551 #if !defined(GARBAGE_COLLECT)
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10552 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
10553 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
10554 #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
10555 _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
10556
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
10557 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
10558
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
10559 /* 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
10560 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
10561
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
10562 /* 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
10563 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
10564 [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
10565 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
10566 [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
10567 #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
10568 pool = pthread_getspecific(_dw_pool_key);
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10569 [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
10570 #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
10571 free(tmp);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10572 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10573
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
10574 /*
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
10575 * 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
10576 * 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
10577 * 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
10578 */
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
10579 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
10580 {
1241
459426f31fb4 Slight thread safety fix on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1239
diff changeset
10581 NSFont *oldfont = DWDefaultFont;
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
10582 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
10583 [DWDefaultFont retain];
1241
459426f31fb4 Slight thread safety fix on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1239
diff changeset
10584 [oldfont release];
744
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
10585 }
9882b0dfa304 Added an internal Mac function for setting the default Dynamic Windows font.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 743
diff changeset
10586
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10587 /*
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10588 * 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
10589 * Parameters:
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10590 * 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
10591 * 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
10592 */
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10593 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
10594 {
1786
9a32d4216f24 Make sure we set the locale on Mac and it is UTF-8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
10595 char *lang = getenv("LANG");
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10596
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
10597 /* 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
10598 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
10599 {
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
10600 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
10601 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
10602
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
10603 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
10604 {
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10605 char pathbuf[PATH_MAX+1] = { 0 };
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10606 size_t len = (size_t)(app - pathcopy);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10607
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10608 if(len > 0)
1385
fc20ad815428 Don't need to include the / after the .app on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1384
diff changeset
10609 strncpy(_dw_bundle_path, pathcopy, len + 4);
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
10610 *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
10611
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
10612 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
10613
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
10614 /* 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
10615 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
10616 {
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10617 char *pos = strrchr(pathcopy, '/');
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10618
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10619 if(pos)
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
10620 {
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10621 strncpy(pathbuf, pathcopy, (size_t)(pos - pathcopy));
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10622 chdir(pathbuf);
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
10623 }
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
10624 }
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
10625 }
1383
ead81c3d9e4e Thought I was fixing a memory leak but I was seeing the {} wrong.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
10626 if(pathcopy)
ead81c3d9e4e Thought I was fixing a memory leak but I was seeing the {} wrong.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
10627 free(pathcopy);
ead81c3d9e4e Thought I was fixing a memory leak but I was seeing the {} wrong.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
10628 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10629
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10630 /* Just in case we can't obtain a path */
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10631 if(!_dw_bundle_path[0])
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1378
diff changeset
10632 getcwd(_dw_bundle_path, PATH_MAX);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10633
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
10634 /* Get the operating system version */
1770
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
10635 NSString *version = [[NSProcessInfo processInfo] operatingSystemVersionString];
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
10636 const char *versionstr = [version UTF8String];
2396655d43f1 Fix some warnings with Mac 10.8 and Xcode 4.5.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
10637 sscanf(versionstr, "Version %d.%d.%d", &DWOSMajor, &DWOSMinor, &DWOSBuild);
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10638 /* Set the locale... if it is UTF-8 pass it
1786
9a32d4216f24 Make sure we set the locale on Mac and it is UTF-8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
10639 * directly, otherwise specify UTF-8 explicitly.
9a32d4216f24 Make sure we set the locale on Mac and it is UTF-8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
10640 */
9a32d4216f24 Make sure we set the locale on Mac and it is UTF-8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
10641 setlocale(LC_ALL, lang && strstr(lang, ".UTF-8") ? lang : "UTF-8");
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
10642 /* 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
10643 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
10644 /* 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
10645 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
10646 /* 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
10647 #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
10648 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
10649 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
10650 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
10651 #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
10652 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
10653 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
10654 _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
10655 /* 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
10656 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
10657 [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
10658 [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
10659 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
10660 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
10661 /* 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
10662 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
10663 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
10664 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
10665 /* 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
10666 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
10667 [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
10668 [thread release];
859
80a88c91ccf6 Implemented vertical centering on text fields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 858
diff changeset
10669 [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
10670 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
10671 }
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10672
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10673 /*
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10674 * 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
10675 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10676 * 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
10677 * 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
10678 * 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
10679 * 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
10680 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10681 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
10682 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
10683 char namebuf[1025] = {0};
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10684 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
10685
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10686 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
10687 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10688
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10689 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
10690 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10691 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10692 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10693 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10694
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10695 ftruncate(handle->fd, size);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10696
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10697 /* 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
10698 *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
10699
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10700 if(*dest == MAP_FAILED)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10701 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 close(handle->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 *dest = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10704 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10707
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 handle->size = size;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10709 handle->sid = getsid(0);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 handle->path = strdup(namebuf);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 return handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 * 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
10717 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718 * 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
10719 * 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
10720 * 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
10721 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10722 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
10723 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
10724 char namebuf[1025];
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10725 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
10726
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10727 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
10728 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10729
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10730 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
10731 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10732 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10733 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10734 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10735
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10736 /* 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
10737 *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
10738
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10739 if(*dest == MAP_FAILED)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10740 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10741 close(handle->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10742 *dest = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10743 free(handle);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10744 return NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10745 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10746
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10747 handle->size = size;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10748 handle->sid = -1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10749 handle->path = NULL;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10750
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10751 return handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10752 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10753
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10754 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10755 * 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
10756 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10757 * 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
10758 * 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
10759 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10760 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
10761 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10762 struct _dw_unix_shm *h = handle;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10763 int rc = munmap(ptr, h->size);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10764
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10765 close(h->fd);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10766 if(h->path)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10767 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10768 /* 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
10769 * creator of the file.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10770 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10771 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
10772 remove(h->path);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10773 free(h->path);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10774 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10775 return rc;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 }
697
830e1f3672b9 Added draining mechanism for threads that don't have run loops.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 696
diff changeset
10777
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10779 * 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
10780 * Parameters:
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10781 * 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
10782 * 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
10783 * 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
10784 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10785 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
10786 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10787 DWTID thread;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10788 void **tmp = malloc(sizeof(void *) * 2);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10789 int rc;
650
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 tmp[0] = func;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 tmp[1] = data;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 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
10795 if(rc == 0)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 return thread;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 return (DWTID)-1;
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 * Ends execution of current thread immediately.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10803 void dw_thread_end(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10805 pthread_exit(NULL);
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10806 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10807
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10808 /*
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10809 * Returns the current thread's ID.
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10810 */
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10811 DWTID dw_thread_id(void)
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10812 {
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10813 return (DWTID)pthread_self();
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10814 }
55b677d460e9 Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10815
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10816 /*
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10817 * 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
10818 * Parameters:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10819 * program: Program name with optional path.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10820 * 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
10821 * 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
10822 * Returns:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10823 * -1 on error.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10824 */
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10825 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
10826 {
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10827 int ret = -1;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10828
738
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10829 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
10830 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10831 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
10832 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10833 [[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
10834 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
10835 }
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10836 else
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10837 {
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10838 [[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
10839 }
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10840 return 0;
52d5ed00f892 Use NSWorkplace to launch GUI applications instead of fork() and exec().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 737
diff changeset
10841 }
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10842
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10843 if((ret = fork()) == 0)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10844 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10845 int i;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10846
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10847 for (i = 3; i < 256; i++)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10848 close(i);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10849 setsid();
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10850
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10851 if(type == DW_EXEC_CON)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10852 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10853 char **tmpargs;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10854
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10855 if(!params)
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10856 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10857 tmpargs = malloc(sizeof(char *));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10858 tmpargs[0] = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10859 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10860 else
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10861 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10862 int z = 0;
762
2aaa3f67cfb1 Fix for crashes with generating images from data
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 760
diff changeset
10863
752
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10864 while(params[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10865 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10866 z++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10867 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10868 tmpargs = malloc(sizeof(char *)*(z+3));
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10869 z=0;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10870 tmpargs[0] = "xterm";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10871 tmpargs[1] = "-e";
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10872 while(params[z])
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10873 {
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10874 tmpargs[z+2] = params[z];
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10875 z++;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10876 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10877 tmpargs[z+2] = NULL;
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10878 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10879 execvp("xterm", tmpargs);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10880 free(tmpargs);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10881 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10882 /* If we got here exec failed */
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10883 _exit(-1);
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10884 }
cf447811d322 Converted tabs to spaces.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 751
diff changeset
10885 return ret;
661
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10886 }
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10887
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10888 /*
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10889 * 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
10890 * Parameters:
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10891 * url: Uniform resource locator.
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10892 */
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10893 int dw_browse(char *url)
eee90a788876 Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 660
diff changeset
10894 {
715
5f8102bd7646 dw_browse() reimplmented so it actually works as expected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 714
diff changeset
10895 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
10896 [[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
10897 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
10898 }
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10899
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10900 typedef struct _dwprint
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10901 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10902 NSPrintInfo *pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10903 int (*drawfunc)(HPRINT, HPIXMAP, int, void *);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10904 void *drawdata;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10905 unsigned long flags;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10906 } DWPrint;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10907
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10908 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10909 * 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
10910 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
10911 * 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
10912 * 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
10913 * 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
10914 * 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
10915 * 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
10916 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10917 * 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
10918 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
10919 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
10920 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10921 DWPrint *print;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10922 NSPrintPanel *panel;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10923 PMPrintSettings settings;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10924 NSPrintInfo *pi;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10925
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10926 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
10927 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10928 return NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10929 }
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10930
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
10931 if(!jobname)
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
10932 jobname = "Dynamic Windows Print Job";
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10933
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10934 print->drawfunc = drawfunc;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10935 print->drawdata = drawdata;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10936 print->flags = flags;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10937
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10938 /* Get the page range */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10939 pi = [NSPrintInfo sharedPrintInfo];
1237
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10940 [pi setHorizontalPagination:NSFitPagination];
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10941 [pi setHorizontallyCentered:YES];
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10942 [pi setVerticalPagination:NSFitPagination];
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10943 [pi setVerticallyCentered:YES];
1239
7ec60b650e5b Printer info should default to Portrait not Landscape on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1237
diff changeset
10944 [pi setOrientation:NSPortraitOrientation];
1237
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10945 [pi setLeftMargin:0.0];
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10946 [pi setRightMargin:0.0];
f8673299ec37 Ok if we setup the print information on Mac we get a better size...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1236
diff changeset
10947 [pi setTopMargin:0.0];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10948 [pi setBottomMargin:0.0];
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10949
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10950 settings = [pi PMPrintSettings];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10951 PMSetPageRange(settings, 1, pages);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10952 PMSetFirstPage(settings, 1, true);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10953 PMSetLastPage(settings, pages, true);
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
10954 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
10955 [pi updateFromPMPrintSettings];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10956
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10957 /* Create and show the print panel */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10958 panel = [NSPrintPanel printPanel];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10959 if(!panel || [panel runModalWithPrintInfo:pi] == NSCancelButton)
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10960 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10961 free(print);
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10962 return NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10963 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10964 /* 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
10965 print->pi = pi;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10966
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10967 return print;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10968 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10969
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10970 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10971 * 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
10972 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10973 * 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
10974 * 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
10975 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10976 * 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
10977 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
10978 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
10979 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10980 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
10981 NSBitmapImageRep *rep, *rep2;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10982 NSPrintInfo *pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10983 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
10984 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
10985 NSImage *image, *flipped;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10986 NSImageView *iv;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10987 NSSize size;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10988 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
10989 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
10990 UInt32 start, end;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10991
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10992 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
10993 return result;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10994
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
10995 DW_LOCAL_POOL_IN;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
10996
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10997 /* Figure out the printer/paper size */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10998 pi = p->pi;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
10999 size = [pi paperSize];
1234
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11000
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11001 /* Get the page range */
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11002 settings = [pi PMPrintSettings];
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11003 PMGetFirstPage(settings, &start);
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11004 if(start > 0)
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11005 start--;
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11006 PMGetLastPage(settings, &end);
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11007 PMSetPageRange(settings, 1, 1);
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11008 PMSetFirstPage(settings, 1, true);
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11009 PMSetLastPage(settings, 1, true);
bee6fc8119ec Paper size reported on Mac height is for all pages...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1230
diff changeset
11010 [pi updateFromPMPrintSettings];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11011
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11012 /* 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
11013 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
11014 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
11015 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
11016 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
11017 rep2 = pixmap2->image;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11018
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11019 /* Create an image with the data from the pixmap
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11020 * to go into the image view.
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11021 */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11022 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
11023 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
11024 [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
11025 [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
11026 [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
11027 [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
11028 [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
11029 [iv setFrameSize:size];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11030
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11031 /* 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
11032 * 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
11033 */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11034 po = [NSPrintOperation printOperationWithView:iv printInfo:pi];
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11035 [po setShowsPrintPanel:NO];
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11036
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11037 /* Cycle through each page */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11038 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
11039 {
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11040 /* Call the application's draw function */
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11041 p->drawfunc(print, pixmap, x, p->drawdata);
1340
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11042 if(p->drawfunc)
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11043 {
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11044 /* Internal representation is flipped... so flip again so we can print */
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11045 _flip_image(image, rep2, size);
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11046 #ifdef DEBUG_PRINT
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11047 /* Save it to file to see what we have */
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11048 NSData *data = [rep2 representationUsingType: NSPNGFileType properties: nil];
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11049 [data writeToFile: @"print.png" atomically: NO];
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11050 #endif
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11051 /* Print the image view */
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11052 [po runOperation];
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11053 /* Fill the pixmap with white in case we are printing more pages */
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11054 dw_color_foreground_set(DW_CLR_WHITE);
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11055 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height);
890890c31ba6 Another printing cancel fix for the Mac and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1335
diff changeset
11056 }
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11057 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
11058 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
11059 result = DW_ERROR_NONE;
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11060 /* 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
11061 [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
11062 [flipped release];
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11063 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
11064 dw_pixmap_destroy(pixmap2);
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11065 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
11066 [iv release];
1582
728778634933 Performed a more thorough audit of functions on Mac that require local pools.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1580
diff changeset
11067 DW_LOCAL_POOL_OUT;
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1141
diff changeset
11068 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11069 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11070
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11071 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11072 * 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
11073 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11074 * 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
11075 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1135
diff changeset
11076 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
11077 {
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11078 DWPrint *p = print;
1802
aedf5903db0a Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1795
diff changeset
11079
1141
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11080 if(p)
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11081 p->drawfunc = NULL;
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11082 }
8d8c73fb27f4 Initial implementation of printing support on Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11083
1783
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11084 /*
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11085 * Converts a UTF-8 encoded string into a wide string.
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11086 * Parameters:
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11087 * utf8string: UTF-8 encoded source string.
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11088 * Returns:
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11089 * Wide string that needs to be freed with dw_free()
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11090 * or NULL on failure.
1783
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11091 */
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11092 wchar_t * API dw_utf8_to_wchar(char *utf8string)
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11093 {
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11094 size_t buflen = strlen(utf8string) + 1;
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11095 wchar_t *temp = malloc(buflen * sizeof(wchar_t));
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11096 if(temp)
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11097 mbstowcs(temp, utf8string, buflen);
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11098 return temp;
1783
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11099 }
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11100
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11101 /*
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11102 * Converts a wide string into a UTF-8 encoded string.
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11103 * Parameters:
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11104 * wstring: Wide source string.
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11105 * Returns:
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11106 * UTF-8 encoded string that needs to be freed with dw_free()
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11107 * or NULL on failure.
1783
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11108 */
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11109 char * API dw_wchar_to_utf8(wchar_t *wstring)
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11110 {
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11111 size_t bufflen = 8 * wcslen(wstring) + 1;
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11112 char *temp = malloc(bufflen);
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11113 if(temp)
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1783
diff changeset
11114 wcstombs(temp, wstring, bufflen);
1783
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11115 return temp;
9de6d1cc8fb8 Put test program code into DEPRECATED #ifdef again to avoid build warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1782
diff changeset
11116 }