annotate win/dw.c @ 1853:4790589f52a9

Initial commit for new dw_signal_connect_data() function... Same as dw_signal_connect() but it has an additional callback parameter that gets called when the callback is being removed. This allows me to free memory allocated for the data parameter and prevent memory leaks in godwindows... Tested GTK and Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 27 Feb 2013 19:14:22 +0000
parents 905f8632005b
children 285bf986e4fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3 * A GTK like implementation of the Win32 GUI
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
5 * (C) 2000-2013 Brian Smith <brian@dbsoft.org>
1386
fd1de4e9e542 Updated the readme and comments in the source files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1384
diff changeset
6 * (C) 2003-2011 Mark Hessling <mark@rexx.org>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
9
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
10 #ifdef AEROGLASS
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11 #define _WIN32_IE 0x0501
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12 #define WINVER 0x501
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
13 #else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
14 #define _WIN32_IE 0x0500
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
15 #define WINVER 0x500
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
16 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
17 #include <windows.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
18 #include <windowsx.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
19 #include <commctrl.h>
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
20 #include <shlwapi.h>
449
787cc1e27897 Add support for directory browsing under Win32. DW_DIRECTORY_OPEN can be
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 448
diff changeset
21 #include <shlobj.h>
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
22 #include <userenv.h>
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
23 #include <tchar.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 #include <process.h>
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
28 #include <malloc.h>
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
29 #include <io.h>
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
30 #include <time.h>
1633
c441c85baa57 Fix rendering Arc segments in anti-antialiased mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1632
diff changeset
31 #define _USE_MATH_DEFINES
1268
148daf522080 Fixed on Windows sqrt() issue due to missing header...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1261
diff changeset
32 #include <math.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 #include "dw.h"
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
34 #ifdef BUILD_DLL
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
35 #include "XBrowseForFolder.h"
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
36 #endif
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
37 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
38 #include <uxtheme.h>
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
39 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
40 #include <richedit.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
42 #define STATICCLASSNAME TEXT("STATIC")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
43 #define COMBOBOXCLASSNAME TEXT("COMBOBOX")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
44 #define LISTBOXCLASSNAME TEXT("LISTBOX")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
45 #define BUTTONCLASSNAME TEXT("BUTTON")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
46 #define POPUPMENUCLASSNAME TEXT("POPUPMENU")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
47 #define EDITCLASSNAME TEXT("EDIT")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
48 #define FRAMECLASSNAME TEXT("FRAME")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
49 #define SCROLLBARCLASSNAME TEXT("SCROLLBAR")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
50
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
51 #define ClassName TEXT("dynamicwindows")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
52 #define SplitbarClassName TEXT("dwsplitbar")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
53 #define ObjectClassName TEXT("dwobjectclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
54 #define BrowserClassName TEXT("dwbrowserclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
55 #define ScrollClassName TEXT("dwscrollclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
56 #define StatusbarClassName TEXT("dwstatusbar")
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
57 #define DefaultFont NULL
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
58
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
59 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
60 /* GDI+ Headers are not C compatible... so define what we need here instead */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
61 struct GdiplusStartupInput
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
62 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
63 UINT32 GdiplusVersion;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
64 void *DebugEventCallback;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
65 BOOL SuppressBackgroundThread;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
66 BOOL SuppressExternalCodecs;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
67 };
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
68
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
69 typedef enum {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
70 Ok = 0,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
71 GenericError = 1,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
72 InvalidParameter = 2,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
73 OutOfMemory = 3,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
74 ObjectBusy = 4,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
75 InsufficientBuffer = 5,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
76 NotImplemented = 6,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
77 Win32Error = 7,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
78 WrongState = 8,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
79 Aborted = 9,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
80 FileNotFound = 10,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
81 ValueOverflow = 11,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
82 AccessDenied = 12,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
83 UnknownImageFormat = 13,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
84 FontFamilyNotFound = 14,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
85 FontStyleNotFound = 15,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
86 NotTrueTypeFont = 16,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
87 UnsupportedGdiplusVersion = 17,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
88 GdiplusNotInitialized = 18,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
89 PropertyNotFound = 19,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
90 PropertyNotSupported = 20,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
91 ProfileNotFound = 21
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
92 } GpStatus;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
93
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
94 typedef enum {
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
95 UnitWorld,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
96 UnitDisplay,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
97 UnitPixel,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
98 UnitPoint,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
99 UnitInch,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
100 UnitDocument,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
101 UnitMillimeter
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
102 } GpUnit;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
103
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
104 typedef enum {
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
105 FlushIntentionFlush = 0,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
106 FlushIntentionSync = 1
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
107 } GpFlushIntention;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
108
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
109 typedef enum {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
110 QualityModeInvalid = -1,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
111 QualityModeDefault = 0,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
112 QualityModeLow = 1,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
113 QualityModeHigh = 2
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
114 } QualityMode;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
115
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
116 typedef enum {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
117 SmoothingModeInvalid = QualityModeInvalid,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
118 SmoothingModeDefault = QualityModeDefault,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
119 SmoothingModeHighSpeed = QualityModeLow,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
120 SmoothingModeHighQuality = QualityModeHigh,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
121 SmoothingModeNone,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
122 SmoothingModeAntiAlias
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
123 } SmoothingMode;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
124
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
125 typedef void GpGraphics;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
126 typedef void GpPen;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
127 typedef void GpBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
128 typedef void GpBitmap;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
129 typedef void GpImage;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
130 typedef POINT GpPoint;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
131 typedef DWORD ARGB;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
132 typedef float REAL;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
133
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
134 #define ALPHA_SHIFT 24
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
135 #define RED_SHIFT 16
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
136 #define GREEN_SHIFT 8
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
137 #define BLUE_SHIFT 0
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
138 #define ALPHA_MASK ((ARGB) 0xff << ALPHA_SHIFT)
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
139
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
140 #define MAKEARGB(a, r, g, b) \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
141 (((ARGB) ((a) & 0xff) << ALPHA_SHIFT)| \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
142 ((ARGB) ((r) & 0xff) << RED_SHIFT) | \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
143 ((ARGB) ((g) & 0xff) << GREEN_SHIFT)| \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
144 ((ARGB) ((b) & 0xff) << BLUE_SHIFT))
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
145
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
146 /* Graphic conversion functions */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
147 GpStatus WINAPI GdipCreateBitmapFromFile(const WCHAR* filename, GpBitmap **bitmap);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
148 GpStatus WINAPI GdipCreateHBITMAPFromBitmap(GpBitmap *bitmap, HBITMAP* hbmReturn, DWORD background);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
149 GpStatus WINAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hbmReturn);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
150 GpStatus WINAPI GdipDisposeImage(GpImage *image);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
151 GpStatus WINAPI GdipGetImagePixelFormat(GpImage *image, INT *format);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
152 /* Startup and Shutdown */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
153 GpStatus WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, void *output);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
154 VOID WINAPI GdiplusShutdown(ULONG_PTR token);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
155 /* Drawing functions */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
156 GpStatus WINAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
157 GpStatus WINAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
158 GpStatus WINAPI GdipDeleteGraphics(GpGraphics *graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
159 GpStatus WINAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode smoothingMode);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
160 GpStatus WINAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
161 GpStatus WINAPI GdipDeletePen(GpPen *pen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
162 GpStatus WINAPI GdipCreateSolidFill(ARGB color, GpBrush **brush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
163 GpStatus WINAPI GdipDeleteBrush(GpBrush *brush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
164 GpStatus WINAPI GdipSetSolidFillColor(GpBrush *brush, ARGB color);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
165 GpStatus WINAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
166 GpStatus WINAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, const GpPoint *points, INT count);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
167 GpStatus WINAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
168 GpStatus WINAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
169 GpStatus WINAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
170 GpStatus WINAPI GdipDrawPolygonI(GpGraphics *graphics, GpPen *pen, const GpPoint *points, INT count);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
171 GpStatus WINAPI GdipFillPolygon2I(GpGraphics *graphics, GpBrush *brush, const GpPoint *points, INT count);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
172 GpStatus WINAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
173 GpStatus WINAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
174 GpStatus WINAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
175
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
176 /* Pixel format information */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
177 #define PixelFormatIndexed 0x00010000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
178 #define PixelFormatGDI 0x00020000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
179 #define PixelFormatAlpha 0x00040000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
180 #define PixelFormatPAlpha 0x00080000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
181 #define PixelFormatExtended 0x00100000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
182 #define PixelFormatCanonical 0x00200000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
183
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
184 #define PixelFormatUndefined 0
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
185 #define PixelFormatDontCare 0
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
186
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
187 #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
188 #define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
189 #define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
190 #define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
191 #define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
192 #define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
193 #define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
194 #define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
195 #define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
196 #define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
197 #define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
198 #define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
199 #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
200 #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
201 #define PixelFormat32bppCMYK (15 | (32 << 8))
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
202
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
203 /* Token to the GDI+ Instance */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
204 ULONG_PTR gdiplusToken;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
205 #endif
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
206
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
207 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
208 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
209 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0;
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
210 HTHEME (WINAPI *_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
211 HPAINTBUFFER (WINAPI *_BeginBufferedPaint)(HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
212 HRESULT (WINAPI *_BufferedPaintSetAlpha)(HPAINTBUFFER hBufferedPaint, const RECT *prc, BYTE alpha) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
213 HRESULT (WINAPI *_DrawThemeTextEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwFlags, LPRECT pRect, const DTTOPTS *pOptions) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
214 HRESULT (WINAPI *_EndBufferedPaint)(HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
215 HRESULT (WINAPI *_CloseThemeData)(HTHEME hTheme) = 0;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
216 BOOL _dw_composition = FALSE;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
217 COLORREF _dw_transparencykey = RGB(200,201,202);
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
218 HANDLE hdwm = 0;
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
219 #endif
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
220 /* Aero related but separate functions and handles */
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
221 HRESULT (WINAPI *_SetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) = 0;
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
222 HANDLE huxtheme = 0;
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
223
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
224 /* Needed for Rich Edit controls */
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
225 HANDLE hrichedit = 0;
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
226
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
227 /*
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
228 * MinGW Is missing a bunch of definitions
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
229 * so #define them here...
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
230 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
231
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
232 #if !defined( _tstol )
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
233 #if defined(UNICODE)
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
234 # define _tstol _wtol
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
235 #else
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
236 # define _tstol atol
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
237 #endif
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
238 #endif
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
239 #if !defined(PBS_MARQUEE)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
240 # define PBS_MARQUEE 0x08
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
241 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
242 #if !defined(PBM_SETMARQUEE)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
243 # define PBM_SETMARQUEE (WM_USER+10)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
244 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
245 #if !defined(LVS_EX_DOUBLEBUFFER)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
246 # define LVS_EX_DOUBLEBUFFER 0x10000
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
247 #endif
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
248
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
249 HWND popup = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL, hwndTooltip = (HWND)0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
250
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
251 HINSTANCE DWInstance = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
252
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
253 DWORD dwVersion = 0, dwComctlVer = 0;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
254 DWTID _dwtid = -1;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
255 SECURITY_DESCRIPTOR _dwsd;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
256
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
257 #define PACKVERSION(major,minor) MAKELONG(minor,major)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
258
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
259 #define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82))
1119
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
260 #define IS_VISTAPLUS (dwComctlVer >= PACKVERSION(6,10))
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
261
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
262 #ifndef MIN
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
263 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
264 #endif
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
265
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
266 /*
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
267 * For the dw*from_data() functions, a temporary file is required to write
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
268 * the contents of the image to so it can be loaded by the Win32 API
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
269 * We use _tempnam() which uses TMP env variable by default. It can be passed
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
270 * an alternate temporary directory if TMP is not set, so we get the value
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
271 * of TEMP and store it here.
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
272 */
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
273 static char _dw_alternate_temp_dir[MAX_PATH+1] = {0};
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
274 static char _dw_exec_dir[MAX_PATH+1] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
275
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
276 int main(int argc, char *argv[]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
277
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
278 #define ICON_INDEX_LIMIT 200
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
279 HICON lookup[200];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
280 HIMAGELIST hSmall = 0, hLarge = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
281
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
282 /* Special flag used for internal tracking */
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
283 #define DW_CFA_RESERVED (1 << 30)
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
284
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
285 DWORD _foreground;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
286 DWORD _background;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
287 DWORD _hPen;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
288 DWORD _hBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
289 #ifdef GDIPLUS
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
290 DWORD _gpPen;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
291 DWORD _gpBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
292 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
294 BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
295 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
296 BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
297 0x00, 0xff, 0xee, 0x00, 0x00, 0xee, 0xff, 0xaa, 0x00 };
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
298 BYTE _blue[] = { 0x00, 0x00, 0x00, 0x00, 0xcc, 0xbb, 0xbb, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
299 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00};
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
300
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
301 HBRUSH _colors[18];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
302
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: 1073
diff changeset
303 HFONT _DefaultFont = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
305 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
306 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
307 #endif
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
308 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
309 void _resize_notebook_page(HWND handle, int pageid);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
310 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
311 int _lookup_icon(HWND handle, HICON hicon, int type);
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
312 HFONT _acquire_font(HWND handle, char *fontname);
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
313 void _click_default(HWND handle);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
314 void _do_resize(Box *thisbox, int x, int y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
315
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
316 /* Internal function to queue a window redraw */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
317 void _dw_redraw(HWND window, int skip)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
318 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
319 static HWND lastwindow = 0;
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
320 HWND redraw = lastwindow;
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
321
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
322 if(skip && !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
323 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
324
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
325 lastwindow = window;
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
326 if(redraw != lastwindow && redraw)
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
327 {
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
328 dw_window_redraw(redraw);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
329 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
330 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
331
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 typedef struct _sighandler
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
334 struct _sighandler *next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
335 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
336 HWND window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
337 int id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
338 void *signalfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
339 void *discfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
340 void *data;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 SignalHandler *Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
348 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
349 char name[30];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
353 static int in_checkbox_handler = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
354
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
355 /* List of signals and their equivilent Win32 message */
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
356 #define SIGNALMAX 17
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358 SignalList SignalTranslate[SIGNALMAX] = {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
359 { WM_SIZE, DW_SIGNAL_CONFIGURE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
360 { WM_CHAR, DW_SIGNAL_KEY_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
361 { WM_LBUTTONDOWN, DW_SIGNAL_BUTTON_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
362 { WM_LBUTTONUP, DW_SIGNAL_BUTTON_RELEASE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
363 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
364 { WM_CLOSE, DW_SIGNAL_DELETE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
365 { WM_PAINT, DW_SIGNAL_EXPOSE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
366 { WM_COMMAND, DW_SIGNAL_CLICKED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
367 { NM_DBLCLK, DW_SIGNAL_ITEM_ENTER },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
368 { NM_RCLICK, DW_SIGNAL_ITEM_CONTEXT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
369 { LBN_SELCHANGE, DW_SIGNAL_LIST_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
370 { TVN_SELCHANGED, DW_SIGNAL_ITEM_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
371 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
372 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
373 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
374 { LVN_COLUMNCLICK, DW_SIGNAL_COLUMN_CLICK },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
375 { TVN_ITEMEXPANDED,DW_SIGNAL_TREE_EXPAND }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
378 #ifdef BUILD_DLL
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
379 void Win32_Set_Instance(HINSTANCE hInstance)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
380 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
381 DWInstance = hInstance;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
382 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
383 #else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
384 char **_convertargs(int *count, char *start)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
385 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
386 char *tmp, *argstart, **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
387 int loc = 0, inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
388
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
389 (*count) = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
390
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
391 tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
392
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
393 /* Count the number of entries */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
394 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
395 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
396 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
397
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
398 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
399 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
400 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
401 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
402 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
403 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
404 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
405 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
406 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
407 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
408 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
409 /* If we aren't at the end of the command
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
410 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
411 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
412 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
413 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
414 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
415 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
416 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
417 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
418
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
419 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
420 argv[0] = malloc(260);
1620
32b5fba0b00a Must convert from UTF8 for the raw HTML on Windows regardless of the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1618
diff changeset
421 GetModuleFileNameA(DWInstance, argv[0], 260);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
422
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
423 argstart = tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
424
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
425 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
426 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
427 loc = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
428
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
429 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
430 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
431 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
432 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
433 *tmp = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
434 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
435 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
436 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
437 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
438 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
439 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
440 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
441 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
442 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
443 *tmp = 0;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
444 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
445
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
446 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
447 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
448 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
449
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
450 /* Move the start pointer */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
451 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
452
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
453 /* If we aren't at the end of the command
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
454 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
455 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
456 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
457 loc++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
458 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
459 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
460 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
461 if(*argstart)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
462 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
463 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
464 argv[loc+1] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
465 return argv;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
466 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
467
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
468 /* Ok this is a really big hack but what the hell ;) */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
469 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
470 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
471 char **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
472 int argc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
473
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
474 DWInstance = hInstance;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
475
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
476 argv = _convertargs(&argc, lpCmdLine);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
477
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
478 return main(argc, argv);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
479 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
480 #endif
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
481
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
482 #ifdef UNICODE
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
483 /* Macro and internal function to convert UTF8 to Unicode wide characters */
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
484 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
485 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
486 {
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
487 LPWSTR retbuf = outbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
488
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
489 if(retbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
490 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR));
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
491 return retbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
492 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
493 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
494 char *_myWideToUTF8(LPWSTR widestring, void *outbuf)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
495 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
496 char *retbuf = outbuf;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
497
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
498 if(retbuf)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
499 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
500 return retbuf;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
501 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
502 #else
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
503 #define UTF8toWide(a) a
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
504 #define WideToUTF8(a) a
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
505 #endif
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
506
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
507 DWORD GetDllVersion(LPCTSTR lpszDllName)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
508 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
509
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
510 HINSTANCE hinstDll;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
511 DWORD dwVersion = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
513 hinstDll = LoadLibrary(lpszDllName);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
514
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
515 if(hinstDll)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
516 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
517 DLLGETVERSIONPROC pDllGetVersion;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
518
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
519 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
520
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
521 /* Because some DLLs might not implement this function, you
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
522 * must test for it explicitly. Depending on the particular
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
523 * DLL, the lack of a DllGetVersion function can be a useful
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
524 * indicator of the version.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
525 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
526 if(pDllGetVersion)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
527 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
528 DLLVERSIONINFO dvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
529 HRESULT hr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
530
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
531 ZeroMemory(&dvi, sizeof(dvi));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
532 dvi.cbSize = sizeof(dvi);
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
533
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
534 hr = (*pDllGetVersion)(&dvi);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
535
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
536 if(SUCCEEDED(hr))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
537 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
538 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
539 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
540 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
541
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
542 FreeLibrary(hinstDll);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
543 }
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
544 return dwVersion;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
545 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
546
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
547 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
548 /*
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
549 * List those icons that have transparency first
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
550 * GDI+ List of supported formats: BMP, ICON, GIF, JPEG, Exif, PNG, TIFF, WMF, and EMF.
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
551 * Not sure if we should include all these or not... maybe we should add TIFF and GIF?
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
552 */
1255
363d859e8372 Fixed GDI+ loading files with no extension needed. Fixed the *_from_data() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1252
diff changeset
553 #define NUM_EXTS 8
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
554 char *image_exts[NUM_EXTS] =
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
555 {
1255
363d859e8372 Fixed GDI+ loading files with no extension needed. Fixed the *_from_data() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1252
diff changeset
556 "",
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
557 ".png",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
558 ".ico",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
559 ".gif",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
560 ".jpg",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
561 ".jpeg",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
562 ".tiff",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
563 ".bmp"
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
564 };
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
565
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
566 /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
567 void *_dw_load_gpbitmap( char *filename )
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
568 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
569 int i, wclen = (int)(strlen(filename) + 6) * sizeof(wchar_t);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
570 char *file = _alloca(strlen(filename) + 6);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
571 wchar_t *wfile = _alloca(wclen);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
572 void *image;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
573
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
574 /* Try various extentions */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
575 for ( i = 0; i < NUM_EXTS; i++ )
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
576 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
577 strcpy( file, filename );
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
578 strcat( file, image_exts[i] );
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
579 if ( _access( file, 04 ) == 0 )
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
580 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
581 /* Convert to wide format */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
582 MultiByteToWideChar(CP_ACP, 0, file, (int)strlen(file)+1, wfile, wclen);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
583 if(!GdipCreateBitmapFromFile(wfile, &image))
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
584 return image;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
585 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
586 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
587 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
588 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
589
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
590 /* Try to load the appropriate image and return the HBITMAP handle */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
591 HBITMAP _dw_load_bitmap(char *filename, unsigned long *depth)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
592 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
593 void *bitmap = _dw_load_gpbitmap(filename);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
594 if(bitmap)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
595 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
596 HBITMAP hbm = NULL;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
597
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
598 if(!GdipCreateHBITMAPFromBitmap(bitmap, &hbm, 0))
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
599 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
600 if(depth)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
601 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
602 INT pf;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
603
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
604 /* Default to 0 */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
605 *depth = 0;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
606
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
607 /* Query the pixel format so we can determine the depth */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
608 if(!GdipGetImagePixelFormat(bitmap, &pf))
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
609 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
610 switch(pf)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
611 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
612 case PixelFormat1bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
613 *depth = 1;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
614 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
615 case PixelFormat4bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
616 *depth = 4;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
617 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
618 case PixelFormat8bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
619 *depth = 8;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
620 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
621 case PixelFormat16bppGrayScale:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
622 case PixelFormat16bppRGB555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
623 case PixelFormat16bppRGB565:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
624 case PixelFormat16bppARGB1555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
625 *depth = 16;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
626 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
627 case PixelFormat24bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
628 *depth = 24;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
629 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
630 case PixelFormat32bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
631 case PixelFormat32bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
632 case PixelFormat32bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
633 case PixelFormat32bppCMYK:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
634 *depth = 32;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
635 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
636 case PixelFormat48bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
637 *depth = 48;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
638 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
639 case PixelFormat64bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
640 case PixelFormat64bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
641 *depth = 64;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
642 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
643 }
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
644 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
645 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
646 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
647 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
648 return hbm;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
649 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
650 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
651 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
652
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
653 /* Try to load the appropriate image and return the HICON handle */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
654 HICON _dw_load_icon(char *filename)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
655 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
656 void *bitmap = _dw_load_gpbitmap(filename);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
657 if(bitmap)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
658 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
659 HICON hicon = NULL;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
660
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
661 GdipCreateHICONFromBitmap(bitmap, &hicon);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
662 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
663 return hicon;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
664 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
665 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
666 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
667 #endif
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
668
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 */
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
671 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
673 SignalHandler *new = malloc(sizeof(SignalHandler));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
674
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
675 new->message = message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
676 new->window = window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
677 new->id = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
678 new->signalfunction = signalfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
679 new->discfunction = discfunc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
680 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
681 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
682
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
683 if (!Root)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
684 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
685 Root = new;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
686 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
687 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
688 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
689 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
690 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
691 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
692 if(tmp->message == message &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
693 tmp->window == window &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
694 tmp->id == id &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
695 tmp->signalfunction == signalfunction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
696 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
697 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
698 free(new);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
699 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
700 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
701 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
702 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
703 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
704 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
705 prev->next = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
706 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
707 Root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
708 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
714 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
715
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
716 for(z=0;z<SIGNALMAX;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
717 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
718 if(_stricmp(signame, SignalTranslate[z].name) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
719 return SignalTranslate[z].message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
720 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
721 return 0L;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
724 /* This function removes any handlers on windows and frees
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
725 * the user memory and resources allocated to it.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
727 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
728 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
729 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
730 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
731 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
732 TCHAR tmpbuf[100] = {0};
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
733
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
734 TOOLINFO ti = { 0 };
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
735
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
736 ti.cbSize = sizeof(TOOLINFO);
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
737 ti.hwnd = handle;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
738 ti.hinst = DWInstance;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
739
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
740 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
741
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
742 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
743
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
744 /* Don't try to free memory from an OLE embedded IE */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
745 if(_tcsncmp(tmpbuf, TEXT("Internet Explorer_Server"), 25) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
746 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
747
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
748 /* Delete font, icon and bitmap GDI objects in use */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
749 if(oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
750 DeleteObject(oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
751 if(oldicon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
752 DeleteObject(oldicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
753
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
754 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
755 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
756 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
757
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
758 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
759 DeleteObject(oldbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
760 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
761 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
762 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
763 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
764 HICON oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
765
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
766 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
767 DeleteObject(oldbitmap);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
768 if(oldicon)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
769 DestroyIcon(oldicon);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
770 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
771 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
772 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
773 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
774 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
775 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
776 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
777
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
778 SendMessage(handle, TB_SETIMAGELIST, 0, 0);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
779 SendMessage(handle, TB_SETDISABLEDIMAGELIST, 0, 0);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
780
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
781 if(imlist)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
782 ImageList_Destroy(imlist);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
783 if(dimlist)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
784 ImageList_Destroy(dimlist);
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
785 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
786 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
787 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
789 Box *box = (Box *)thiscinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
790
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
791 if(box && box->count && box->items)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
792 free(box->items);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
793 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
794 else if(_tcsnicmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
795 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
796 void *data = dw_window_get_data(handle, "_dw_percent");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
797
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
798 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
799 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
800 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
801 else if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
802 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
803 dw_tree_clear(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
804 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
805 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL)+1)==0) /* Notebook */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
806 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
807 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
808
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
809 if(array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
810 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
811 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
813 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
814 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
815 if(array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
816 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
817 _free_window_memory(array[z]->hwnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
818 EnumChildWindows(array[z]->hwnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
819 DestroyWindow(array[z]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
820 free(array[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
821 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
822 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
823 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
824 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
825 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
826 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0)
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
827 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
828 /* for spinbuttons, we need to get the spinbutton's "buddy", the text window associated and destroy it */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
829 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
830
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
831 if(cinfo && cinfo->buddy)
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
832 DestroyWindow( cinfo->buddy );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
833 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
835 dw_signal_disconnect_by_window(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
836
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
837 if(thiscinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
838 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
839 if(thiscinfo->pOldProc)
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
840 SetWindowLongPtr(handle, GWLP_WNDPROC, (LPARAM)(WNDPROC)thiscinfo->pOldProc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
842 /* Delete the brush so as not to leak GDI objects */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
843 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
844 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
846 /* Free user data linked list memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
847 if(thiscinfo->root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
848 dw_window_set_data(handle, NULL, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
849
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
850 SetWindowLongPtr(handle, GWLP_USERDATA, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
851 free(thiscinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
852 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
853 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855
468
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
856 void _free_menu_data(HMENU menu)
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
857 {
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
858 int i, count = GetMenuItemCount(menu);
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
859
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
860 for(i=0;i<count;i++)
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
861 {
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
862 MENUITEMINFO mii;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
863
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
864 mii.cbSize = sizeof(MENUITEMINFO);
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
865 mii.fMask = MIIM_SUBMENU | MIIM_ID;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
866
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
867 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) )
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
868 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
869 /* Free the data associated with the ID */
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
870 if(mii.wID >= 30000)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
871 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
872 char buffer[31] = {0};
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
873
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
874 _snprintf(buffer, 30, "_dw_id%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
875 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
876 _snprintf(buffer, 30, "_dw_checkable%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
877 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
878 _snprintf(buffer, 30, "_dw_ischecked%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
879 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
880 _snprintf(buffer, 30, "_dw_isdisabled%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
881 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
882 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
883
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
884 /* Check any submenus */
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
885 if( mii.hSubMenu )
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
886 _free_menu_data(mii.hSubMenu);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
887 }
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
888 }
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
889 dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED);
468
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
890 }
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
891
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
892 /* Convert to our internal color scheme */
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
893 ULONG _internal_color(ULONG color)
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
894 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
895 if(color == DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
896 return DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
897 if(color < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
898 return DW_RGB(_red[color], _green[color], _blue[color]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
899 return color;
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
900 }
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
901
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
907 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
909 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
910 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
911
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
912 if(!IsWindowEnabled(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
913 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
914
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
915 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
916
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
917 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
918 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
919 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
920 if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1)==0 || /* Entryfield */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
921 _tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 || /* Button */
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
922 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
923 _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 || /* Toolbar */
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
924 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
925 _tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
926 _tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1)==0 || /* List box */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
927 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
928 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
929 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
930 _tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) /* Tree */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
931 return 1;
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
932 /* Special case for the notebook, can get focus and contains other items */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
933 if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
934 return 2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
935 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
938 HWND _normalize_handle(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
939 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
940 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
941
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
942 GetClassName(handle, tmpbuf, 99);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
943 if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS))==0) /* Spinner */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
944 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
945 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
947 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
948 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
949 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
950 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME))==0) /* Combobox */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
951 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
952 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
954 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
955 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
956 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
957 return handle;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
958 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
959
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
960 #define _DW_DIRECTION_FORWARD -1
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
961 #define _DW_DIRECTION_BACKWARD 1
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
962
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
963 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
964
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
965 /* Internal comparision function */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
966 int _focus_comp(int direction, int z, int end)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
967 {
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
968 if(direction == _DW_DIRECTION_FORWARD)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
969 return z > -1;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
970 return z < end;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
971 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
972
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
973 int _focus_notebook(HWND hwnd, HWND handle, int start, int direction, HWND defaultitem)
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
974 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
975 NotebookPage **array = (NotebookPage **)dw_window_get_data(hwnd, "_dw_array");
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
976 int pageid = TabCtrl_GetCurSel(hwnd);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
977
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
978 if(pageid > -1 && array && array[pageid])
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
979 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
980 Box *notebox;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
981
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
982 if(array[pageid]->hwnd)
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
983 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
984 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
985
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
986 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
987 return 1;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
988 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
989 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
990 return 0;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
991 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
992
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
993 /* Handle box focus traversal in either direction */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
994 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
996 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
997 static HWND lasthwnd, firsthwnd;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
998 static int finish_searching;
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
999 int beg = (direction == _DW_DIRECTION_FORWARD) ? box->count-1 : 0;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1000 int end = (direction == _DW_DIRECTION_FORWARD) ? -1 : box->count;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1002 /* Start is 2 when we have cycled completely and
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1003 * need to set the focus to the last widget we found
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1004 * that was valid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1005 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1006 if(start == 2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1007 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1008 if(lasthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1009 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1010 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1011 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1012
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1013 /* Start is 1 when we are entering the function
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1014 * for the first time, it is zero when entering
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1015 * the function recursively.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1016 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1017 if(start == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1018 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1019 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1020 finish_searching = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1021 firsthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1022 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1023
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1024 for(z=beg;_focus_comp(direction, z, end);z+=direction)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1025 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1026 if(box->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1027 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1028 Box *thisbox = (Box *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1029
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1030 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1031 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1032 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1033 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1034 {
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1035 int type = _validate_focus(box->items[z].hwnd);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1036
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1037 /* Special case notebook, can focus and contains items */
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1038 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1039 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1040 if(box->items[z].hwnd == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1041 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1042 if(lasthwnd == handle && firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1043 SetFocus(firsthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1044 else if(lasthwnd == handle && !firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1045 finish_searching = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1046 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1047 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1048
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1049 /* If we aren't looking for the last handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1050 * return immediately.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1051 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1052 if(!finish_searching)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1053 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1054 }
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1055 if(type > 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1056 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1057 /* Start is 3 when we are looking for the
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1058 * first valid item in the layout.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1059 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1060 if(start == 3)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1061 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1062 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1063 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1064 SetFocus(_normalize_handle(box->items[z].hwnd));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1065 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1066 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1067 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1068
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1069 lasthwnd = _normalize_handle(box->items[z].hwnd);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1070
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1071 if(!firsthwnd)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1072 firsthwnd = lasthwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1073 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1074 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1075 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1076 /* Handle controls that contain other items */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1077 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1078
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1079 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1080
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1081 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1082 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1083 /* Then try the bottom or right box */
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1084 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_bottomright" : "_dw_topleft");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1085
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1086 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1087 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1088 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1089
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1090 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1091 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1092 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1093
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1094 /* Try the top or left box */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1095 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_topleft" : "_dw_bottomright");
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1096
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1097 if(mybox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1098 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1099 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1100
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1101 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1102 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1103 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1104 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1105 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */
903
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1106 {
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1107 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA);
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1108 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA);
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1109
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1110 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
903
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1111 return 1;
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1112 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1113 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1114 /* Special case notebook, can focus and contains items */
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1115 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1116 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1117 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1118 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1119 return 0;
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1120 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1121
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1125 void _initial_focus(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1126 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1127 Box *thisbox;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1128 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1129
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1130 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1131 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1132
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1133 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1134
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1135 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)!=0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1136 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1137
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1138
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1139 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1140 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1141
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1142 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1143 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1144 _focus_check_box(thisbox, handle, 3, _DW_DIRECTION_FORWARD, thisbox->defaultitem);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1145 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1148 HWND _toplevel_window(HWND handle)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1149 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1150 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1151
1803
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1152 if(!lastbox)
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1153 lastbox = handle;
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1154
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1155 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1156 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1157 {
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1158 /* If it hasn't been packed yet.. */
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
1159 if(box == DW_HWND_OBJECT)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
1160 return 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1161 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1162 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1163 if(lastbox)
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1164 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1165 TCHAR tmpbuf[100] = {0};
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1166
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1167 GetClassName(lastbox, tmpbuf, 99);
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1168
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1169 if(_tcsncmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1170 return lastbox;
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1171 }
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1172 return 0;
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1173 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1174
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 */
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1178 void _shift_focus(HWND handle, int direction)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1180 Box *thisbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1181
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1182 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1183
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1184 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1185 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1186 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1187 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1188 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1189
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1190 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1191 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1192 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1193 if(_focus_check_box(thisbox, handle, 1, direction, 0) == 0)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1194 _focus_check_box(thisbox, handle, 2, direction, 0);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1195 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1196 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1197
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 */
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: 1436
diff changeset
1201 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass)
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: 1436
diff changeset
1202 {
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: 1436
diff changeset
1203 /* Current item position */
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: 1436
diff changeset
1204 int z, currentx = thisbox->pad, currenty = thisbox->pad;
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: 1436
diff changeset
1205 /* Used x, y and padding maximum values...
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: 1436
diff changeset
1206 * These will be used to find the widest or
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: 1436
diff changeset
1207 * tallest items in a 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: 1436
diff changeset
1208 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1209 int uymax = 0, uxmax = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1210 int upymax = 0, upxmax = 0;
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: 1436
diff changeset
1211
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: 1436
diff changeset
1212 /* Reset the box sizes */
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: 1436
diff changeset
1213 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1214
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1215 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1216 {
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: 1441
diff changeset
1217 /* Only calculate the size on the first pass...
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: 1441
diff changeset
1218 * use the cached values on second.
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1219 */
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: 1441
diff changeset
1220 if(pass == 1)
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: 1441
diff changeset
1221 {
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: 1441
diff changeset
1222 char *text = dw_window_get_text(thisbox->grouphwnd);
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: 1441
diff changeset
1223
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1224 thisbox->grouppady = 9;
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: 1441
diff changeset
1225
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: 1441
diff changeset
1226 if(text)
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: 1441
diff changeset
1227 {
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: 1441
diff changeset
1228 if(*text)
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: 1441
diff changeset
1229 dw_font_text_extents_get(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady);
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: 1441
diff changeset
1230 dw_free(text);
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: 1441
diff changeset
1231 }
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: 1441
diff changeset
1232 /* If the string height is less than 9...
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: 1441
diff changeset
1233 * set it to 9 anyway since that is the minimum.
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: 1441
diff changeset
1234 */
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: 1441
diff changeset
1235 if(thisbox->grouppady < 9)
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: 1441
diff changeset
1236 thisbox->grouppady = 9;
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1237
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: 1441
diff changeset
1238 if(thisbox->grouppady)
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: 1441
diff changeset
1239 thisbox->grouppady += 3;
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: 1441
diff changeset
1240 else
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: 1441
diff changeset
1241 thisbox->grouppady = 6;
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: 1441
diff changeset
1242
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: 1441
diff changeset
1243 thisbox->grouppadx = 6;
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: 1441
diff changeset
1244 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1245
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: 1436
diff changeset
1246 thisbox->minwidth += thisbox->grouppadx;
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: 1436
diff changeset
1247 thisbox->usedpadx += thisbox->grouppadx;
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: 1436
diff changeset
1248 thisbox->minheight += thisbox->grouppady;
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: 1436
diff changeset
1249 thisbox->usedpady += thisbox->grouppady;
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: 1436
diff changeset
1250 }
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: 1436
diff changeset
1251
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: 1436
diff changeset
1252 /* Count up all the space for all items in the box */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1253 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1254 {
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: 1436
diff changeset
1255 int itempad, itemwidth, itemheight;
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: 1436
diff changeset
1256
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1257 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1258 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1259 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1260
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1261 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1262 {
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: 1436
diff changeset
1263 /* On the first pass calculate the box contents */
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: 1436
diff changeset
1264 if(pass == 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1265 {
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: 1436
diff changeset
1266 (*depth)++;
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: 1436
diff changeset
1267
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: 1436
diff changeset
1268 /* Save the newly calculated values on the 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: 1436
diff changeset
1269 _resize_box(tmp, depth, x, y, pass);
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: 1436
diff changeset
1270
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: 1436
diff changeset
1271 /* Duplicate the values in the item list for use below */
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: 1436
diff changeset
1272 thisbox->items[z].width = tmp->minwidth;
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: 1436
diff changeset
1273 thisbox->items[z].height = tmp->minheight;
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: 1436
diff changeset
1274
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: 1448
diff changeset
1275 /* 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: 1448
diff changeset
1276 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: 1448
diff changeset
1277 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: 1448
diff changeset
1278 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: 1448
diff changeset
1279 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: 1448
diff changeset
1280
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: 1436
diff changeset
1281 (*depth)--;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1282 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1283 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1284 }
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: 1436
diff changeset
1285
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: 1436
diff changeset
1286 /* Precalculate these values, since they will
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: 1436
diff changeset
1287 * be used used repeatedly in the next section.
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: 1436
diff changeset
1288 */
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: 1436
diff changeset
1289 itempad = thisbox->items[z].pad * 2;
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: 1436
diff changeset
1290 itemwidth = thisbox->items[z].width + itempad;
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: 1436
diff changeset
1291 itemheight = thisbox->items[z].height + itempad;
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: 1436
diff changeset
1292
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: 1436
diff changeset
1293 /* Calculate the totals and maximums */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1294 if(thisbox->type == DW_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1295 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1296 if(itemwidth > uxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1297 uxmax = itemwidth;
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: 1436
diff changeset
1298
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1299 if(thisbox->items[z].hsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1300 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1301 if(itemwidth > upxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1302 upxmax = itemwidth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1303 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1304 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1305 {
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: 1436
diff changeset
1306 if(itempad > upxmax)
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: 1436
diff changeset
1307 upxmax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1308 }
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: 1436
diff changeset
1309 thisbox->minheight += itemheight;
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: 1436
diff changeset
1310 if(thisbox->items[z].vsize != SIZEEXPAND)
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: 1436
diff changeset
1311 thisbox->usedpady += itemheight;
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: 1436
diff changeset
1312 else
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: 1436
diff changeset
1313 thisbox->usedpady += itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1314 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1315 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1316 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1317 if(itemheight > uymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1318 uymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1319 if(thisbox->items[z].vsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1320 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1321 if(itemheight > upymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1322 upymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1323 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1324 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1325 {
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: 1436
diff changeset
1326 if(itempad > upymax)
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: 1436
diff changeset
1327 upymax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1328 }
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: 1436
diff changeset
1329 thisbox->minwidth += itemwidth;
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: 1436
diff changeset
1330 if(thisbox->items[z].hsize != SIZEEXPAND)
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: 1436
diff changeset
1331 thisbox->usedpadx += itemwidth;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1332 else
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: 1436
diff changeset
1333 thisbox->usedpadx += itempad;
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: 1436
diff changeset
1334 }
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: 1436
diff changeset
1335 }
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: 1436
diff changeset
1336
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: 1436
diff changeset
1337 /* Add the maximums which were calculated in the previous loop */
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: 1436
diff changeset
1338 thisbox->minwidth += uxmax;
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: 1436
diff changeset
1339 thisbox->minheight += uymax;
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: 1436
diff changeset
1340 thisbox->usedpadx += upxmax;
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: 1436
diff changeset
1341 thisbox->usedpady += upymax;
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: 1436
diff changeset
1342
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: 1436
diff changeset
1343 /* Move the groupbox start past the group border */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1344 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1345 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1346 currentx += 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1347 currenty += thisbox->grouppady - 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1348 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1349
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: 1436
diff changeset
1350 /* The second pass is for actual placement. */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1351 if(pass > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1352 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1353 for(z=0;z<(thisbox->count);z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1354 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1355 int height = thisbox->items[z].height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1356 int width = thisbox->items[z].width;
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: 1436
diff changeset
1357 int itempad = thisbox->items[z].pad * 2;
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: 1436
diff changeset
1358 int thispad = thisbox->pad * 2;
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: 1436
diff changeset
1359
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: 1436
diff changeset
1360 /* Calculate the new sizes */
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: 1436
diff changeset
1361 if(thisbox->items[z].hsize == SIZEEXPAND)
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: 1436
diff changeset
1362 {
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: 1436
diff changeset
1363 if(thisbox->type == DW_HORZ)
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: 1436
diff changeset
1364 {
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: 1436
diff changeset
1365 int expandablex = thisbox->minwidth - thisbox->usedpadx;
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: 1436
diff changeset
1366
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: 1436
diff changeset
1367 if(expandablex)
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: 1436
diff changeset
1368 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
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: 1436
diff changeset
1369 }
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: 1436
diff changeset
1370 else
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: 1436
diff changeset
1371 width = x - (itempad + thispad + thisbox->grouppadx);
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: 1436
diff changeset
1372 }
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: 1436
diff changeset
1373 if(thisbox->items[z].vsize == SIZEEXPAND)
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: 1436
diff changeset
1374 {
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: 1436
diff changeset
1375 if(thisbox->type == DW_VERT)
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: 1436
diff changeset
1376 {
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: 1436
diff changeset
1377 int expandabley = thisbox->minheight - thisbox->usedpady;
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: 1436
diff changeset
1378
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: 1436
diff changeset
1379 if(expandabley)
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: 1436
diff changeset
1380 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
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: 1436
diff changeset
1381 }
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: 1436
diff changeset
1382 else
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: 1436
diff changeset
1383 height = y - (itempad + thispad + thisbox->grouppady);
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: 1436
diff changeset
1384 }
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: 1436
diff changeset
1385
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: 1436
diff changeset
1386 /* If the calculated size is valid... */
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: 1436
diff changeset
1387 if(width > 0 && height > 0)
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: 1436
diff changeset
1388 {
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: 1436
diff changeset
1389 int pad = thisbox->items[z].pad;
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: 1436
diff changeset
1390 HWND handle = thisbox->items[z].hwnd;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1391 TCHAR tmpbuf[100] = {0};
1436
18c1b999dd65 Similar fix for OS/2 and Windows as just committed on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1434
diff changeset
1392
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1393 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1394
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1395 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1396 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1397 /* Handle special case Combobox */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1398 MoveWindow(handle, currentx + pad, currenty + pad,
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: 1436
diff changeset
1399 width, height + 400, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1400 }
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1401 #ifdef TOOLBAR
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1402 /* Bitmap Buttons */
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1403 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1404 {
1731
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1405 SendMessage(handle, TB_SETBUTTONSIZE, 0, MAKELPARAM(width, height));
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1406
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1407 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1408 }
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1409 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1410 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1411 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1412 /* Handle special case Spinbutton */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1413 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1414
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: 1436
diff changeset
1415 MoveWindow(handle, currentx + pad + (width - 20), currenty + pad,
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: 1436
diff changeset
1416 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1417
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1418 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1419 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1420 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad,
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: 1436
diff changeset
1421 width - 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1422 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1423 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1424 else if(_tcsncmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1425 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1426 /* Handle special case of scrollbox */
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1427 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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: 1436
diff changeset
1428 int cx, cy, depth = 0;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1429 Box *thisbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA);
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1430 SCROLLINFO hsi, vsi;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1431 RECT rect;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1432
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1433 vsi.cbSize = hsi.cbSize = sizeof(SCROLLINFO);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1434 vsi.fMask = hsi.fMask = SIF_POS;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1435
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1436 /* Save the current scroll positions */
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1437 GetScrollInfo(handle, SB_HORZ, &hsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1438 GetScrollInfo(handle, SB_VERT, &vsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1439
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1440 /* Position the scrollbox */
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: 1436
diff changeset
1441 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1442
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1443 GetClientRect(handle, &rect);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1444 cx = rect.right;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1445 cy = rect.bottom;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1446
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1447
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1448 /* Get the required space for the box */
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: 1436
diff changeset
1449 _resize_box(thisbox, &depth, cx, cy, 1);
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: 1436
diff changeset
1450
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: 1436
diff changeset
1451 if(cx < thisbox->minwidth)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1452 {
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: 1436
diff changeset
1453 cx = thisbox->minwidth;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1454 }
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: 1436
diff changeset
1455 if(cy < thisbox->minheight)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1456 {
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: 1436
diff changeset
1457 cy = thisbox->minheight;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1458 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1459
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1460 /* Position the scrolled box */
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1461 vsi.fMask = hsi.fMask = SIF_POS | SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1462 vsi.nMin = hsi.nMin = vsi.nMax = hsi.nMax = 0;
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: 1436
diff changeset
1463 if(rect.bottom < thisbox->minheight)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1464 {
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
1465 vsi.nMax = thisbox->minheight - 1;
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1466 vsi.nPage = rect.bottom;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1467 if(vsi.nPos > vsi.nMax)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1468 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1469 vsi.nPos = vsi.nMax;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1470 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1471 }
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: 1436
diff changeset
1472 if(rect.right < thisbox->minwidth)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1473 {
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
1474 hsi.nMax = thisbox->minwidth - 1;
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1475 hsi.nPage = rect.right;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1476 if(hsi.nPos > hsi.nMax)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1477 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1478 hsi.nPos = hsi.nMax;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1479 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1480 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1481 MoveWindow(cinfo->combo, -hsi.nPos, -vsi.nPos, cx, cy, FALSE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1482 SetScrollInfo(handle, SB_HORZ, &hsi, TRUE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1483 SetScrollInfo(handle, SB_VERT, &vsi, TRUE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1484
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1485 /* Layout the content of the scrollbox */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1486 _do_resize(thisbox, cx, cy);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1487 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1488 else if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1489 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1490 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1491 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1492 int type = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_type"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1493
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1494 MoveWindow(handle, currentx + pad, currenty + pad,
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: 1436
diff changeset
1495 width, height, FALSE);
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: 1436
diff changeset
1496
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: 1448
diff changeset
1497 if(percent && width > 0 && height > 0)
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: 1436
diff changeset
1498 _handle_splitbar_resize(handle, *percent, type, width, height);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1499 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1500 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1501 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1502 /* Handle special case Vertically Center static text */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1503 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1504
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1505 if(cinfo && cinfo->vcenter)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1506 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1507 /* We are centered so calculate a new position */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1508 TCHAR tmpbuf[1024] = {0}, *thisbuf = tmpbuf;
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: 1436
diff changeset
1509 int textheight, diff, total = height;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1510
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1511 GetWindowText(handle, thisbuf, 1023);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1513 /* Figure out how big the text is */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1514 dw_font_text_extents_get(handle, 0, WideToUTF8(thisbuf), 0, &textheight);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1515
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1516 diff = (total - textheight) / 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1517
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1518 MoveWindow(handle, currentx + pad, currenty + pad + diff,
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: 1436
diff changeset
1519 width, height - diff, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1520 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1521 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1522 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1523 MoveWindow(handle, currentx + pad, currenty + pad,
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: 1436
diff changeset
1524 width, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1525 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1526 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1527 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1528 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1529 /* Everything else */
1464
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1530 if(*depth)
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1531 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1532 else /* FIXME: This is a hack to generate WM_PAINT messages for items on the top-level */
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1533 SetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, width, height, 0);
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: 1436
diff changeset
1534
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: 1436
diff changeset
1535 /* After placing a box... place its components */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1536 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1537 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1538 Box *boxinfo = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1539
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: 1436
diff changeset
1540 if(boxinfo)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1541 {
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: 1436
diff changeset
1542 /* Move the group border into place */
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: 1436
diff changeset
1543 if(boxinfo->grouphwnd)
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: 1436
diff changeset
1544 {
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: 1436
diff changeset
1545 MoveWindow(boxinfo->grouphwnd, 0, 0,
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: 1436
diff changeset
1546 width, height, FALSE);
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: 1436
diff changeset
1547 }
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: 1436
diff changeset
1548 /* Dive into the 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: 1436
diff changeset
1549 (*depth)++;
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: 1436
diff changeset
1550 _resize_box(boxinfo, depth, width, height, pass);
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: 1436
diff changeset
1551 (*depth)--;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1552 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1553 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1554 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1555
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1556 /* Notebook dialog requires additional processing */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1557 if(_tcsncmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1558 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1559 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1560 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1561 int pageid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1562
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1563 if(pageid > -1 && array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1564 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1565 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1566 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1567 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1568 rect.right - rect.left, rect.bottom-rect.top, FALSE);
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: 1448
diff changeset
1569 dw_window_redraw(array[pageid]->hwnd);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1570 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1571 }
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1572 /* So does the List View... handle delayed cursoring */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1573 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10)
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1574 {
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1575 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor"));
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1576
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1577 if(index > 0)
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1578 ListView_EnsureVisible(handle, index, TRUE);
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1579 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1580
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: 1436
diff changeset
1581 /* Advance the current position in the box */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1582 if(thisbox->type == DW_HORZ)
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: 1436
diff changeset
1583 currentx += width + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1584 if(thisbox->type == DW_VERT)
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: 1436
diff changeset
1585 currenty += height + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1586 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1587 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1588 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1593 if(x != 0 && y != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1594 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1595 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1596 {
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: 1436
diff changeset
1597 int depth = 0;
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: 1436
diff changeset
1598
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: 1436
diff changeset
1599 /* Calculate space requirements */
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: 1436
diff changeset
1600 _resize_box(thisbox, &depth, x, y, 1);
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: 1436
diff changeset
1601
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: 1436
diff changeset
1602 /* Finally place all the boxes and controls */
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: 1436
diff changeset
1603 _resize_box(thisbox, &depth, x, y, 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1604 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1605 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1608 int _HandleScroller(HWND handle, int bar, int pos, int which)
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1609 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1610 SCROLLINFO si;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1611
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1612 ZeroMemory( &si, sizeof(si) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1613 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1614 si.fMask = SIF_ALL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1615
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1616 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1617
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1618 switch(which)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1619 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1620 case SB_THUMBTRACK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1621 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1622 /*case SB_PAGEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1623 case SB_PAGELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1624 pos = si.nPos - si.nPage;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1625 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1626 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1627 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1628 /*case SB_PAGEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1629 case SB_PAGERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1630 pos = si.nPos + si.nPage;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1631 if(pos > (int)(si.nMax - si.nPage) + 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1632 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1633 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1634 /*case SB_LINEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1635 case SB_LINELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1636 pos = si.nPos - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1637 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1638 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1639 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1640 /*case SB_LINEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1641 case SB_LINERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1642 pos = si.nPos + 1;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1643 if(pos > (int)(si.nMax - si.nPage) + 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1644 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1645 return pos;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1646 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1647 return -1;
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1648 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1649
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1650 HMENU _get_owner(HMENU menu)
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1651 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1652 MENUINFO mi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1654 mi.cbSize = sizeof(MENUINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1655 mi.fMask = MIM_MENUDATA;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1656
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
1657 if ( GetMenuInfo( menu, &mi ) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1658 return (HMENU)mi.dwMenuData;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1659 return (HMENU)0;
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1660 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1661
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1662 /* Find the desktop window handle */
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1663 HMENU _menu_owner(HMENU handle)
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1664 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1665 HMENU menuowner = 0, lastowner = _get_owner(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1666
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1667 /* Find the toplevel menu */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1668 while((menuowner = _get_owner(lastowner)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1669 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1670 if(menuowner == (HMENU)1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1671 return lastowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1672 lastowner = menuowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1673 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1674 return (HMENU)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1675 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1676
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1677 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1678 * Determine if this is a checkable menu. If it is get the current state
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1679 * and toggle it. Windows doesn't do this automatically :-(
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1680 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1681 static void _dw_toggle_checkable_menu_item( HWND window, int id )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1682 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1683 char buffer[40];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1684 int checkable;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
1685 sprintf( buffer, "_dw_checkable%d", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1686 checkable = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1687 if ( checkable )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1688 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1689 int is_checked;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
1690 sprintf( buffer, "_dw_ischecked%d", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1691 is_checked = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer));
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1692 is_checked = (is_checked) ? DW_MIS_UNCHECKED : DW_MIS_CHECKED;
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1693 dw_menu_item_set_state( window, id, is_checked );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1694 }
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1695 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1696
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1697 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1698 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1699 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1700 int result = -1, taskbar = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1701 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1702 void (*windowfunc)(PVOID);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1703 ULONG origmsg = msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1704
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1705 /* Deal with translating some messages */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1706 if (msg == WM_USER+2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1707 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1708 taskbar = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1709 origmsg = msg = (UINT)mp2; /* no else here */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1710 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1711 if (msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1712 msg = WM_LBUTTONDOWN;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1713 else if (msg == WM_RBUTTONUP || msg == WM_MBUTTONUP)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1714 msg = WM_LBUTTONUP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1715 else if (msg == WM_HSCROLL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1716 msg = WM_VSCROLL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1717 else if (msg == WM_KEYDOWN) /* && mp1 >= VK_F1 && mp1 <= VK_F24) allow ALL special keys */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1718 msg = WM_CHAR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1719
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1720 if (result == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1721 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1722 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1723 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1724 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1725 if (tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1726 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1727 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1728 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1729 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1730 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1731 if (!hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1732 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1733 int (*timerfunc)(void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1734 if (tmp->id == (int)mp1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1735 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1736 if (!timerfunc(tmp->data))
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1737 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1738 dw_timer_disconnect(tmp->id);
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1739 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1740 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1741 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1742 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1743 result = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1744 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1745 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1746 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1747 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1748 int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1749
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1750 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1751 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1752 result = setfocusfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1753 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1754 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1755 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1756 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1757 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1758 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1759 int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1760 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1761 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1762 result = sizefunc(tmp->window, LOWORD(mp2), HIWORD(mp2), tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1763 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1764 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1765 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1766 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1767 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1768 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1769 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1770
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1771 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1772 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1773 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1774
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1775 switch(origmsg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1776 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1777 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1778 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1779 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1780 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1781 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1782 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1783 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1784 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1785 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1786 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1787 if(taskbar)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1789 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1790 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1791 result = buttonfunc(tmp->window, ptl.x, ptl.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1792 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1793 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1794 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1795 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1796 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1797 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1798 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1799 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1800 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1801 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1802 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1803 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1804 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1806 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1807 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1808 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1810 switch(origmsg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1811 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1812 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1813 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1814 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1815 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1816 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1817 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1818 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1819 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1820 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1821 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1822 if(taskbar)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1823 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1824 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1825 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1826 result = buttonfunc(tmp->window, ptl.x, ptl.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1827 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1828 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1829 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1830 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1831 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1832 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1833 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1834 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1835 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1836 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1837 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1838 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1839 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1840 int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1842 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1843 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1844 int keys = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1846 if (mp1 & MK_LBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1847 keys = DW_BUTTON1_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1848 if (mp1 & MK_RBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1849 keys |= DW_BUTTON2_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1850 if (mp1 & MK_MBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1851 keys |= DW_BUTTON3_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1853 result = motionfunc(tmp->window, pts.x, pts.y, keys, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1854 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1855 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1856 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1857 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1858 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1859 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1860 int (*keypressfunc)(HWND, char, int, int, void *, char *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1861
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1862 if(hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1863 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1864 int special = 0;
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1865 char *utf8 = NULL, ch[2] = {0};
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1866 #ifdef UNICODE
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1867 WCHAR uc[2] = { 0 };
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1868
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1869 uc[0] = (WCHAR)mp1;
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
1870 utf8 = WideToUTF8(&uc[0]);
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1871 #endif
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1872
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1873 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1874 special |= KC_SHIFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1875 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1876 special |= KC_CTRL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1877 if(mp2 & (1 << 29))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1878 special |= KC_ALT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1879
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1880 if(origmsg == WM_CHAR && mp1 < 128)
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1881 ch[0] = (char)mp1;
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1882
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1883 result = keypressfunc(tmp->window, ch[0], (int)mp1, special, tmp->data, utf8 ? utf8 : ch);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1884 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1885 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1886 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1887 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1888 case WM_CLOSE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1889 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1890 int (*closefunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1891
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1892 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1893 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1894 result = closefunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1895 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1896 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1897 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1898 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1899 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1900 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1901 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1902 DWExpose exp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1903 int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1904
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1905 if ( hWnd == tmp->window )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1906 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1907 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1908 exp.x = ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1909 exp.y = ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1910 exp.width = ps.rcPaint.right - ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1911 exp.height = ps.rcPaint.bottom - ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1912 result = exposefunc(hWnd, &exp, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1913 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1914 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1915 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1916 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1917 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1918 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1919 if(tmp->message == TVN_SELCHANGED ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1920 tmp->message == NM_RCLICK ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1921 tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1922 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1923 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1924 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1925 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1926
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1927 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1928
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1929 if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW))==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1930 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1931 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1932 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1933 if(tmp->window == tem->hdr.hwndFrom && !dw_window_get_data(tmp->window, "_dw_select_item"))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1934 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1935 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1936 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1937 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1938
1062
28e63fe64167 Minor changes to the tree handling... added the LVIF_PARAM to make sure that member gets filled in on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1060
diff changeset
1939 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1940 tvi.hItem = tem->itemNew.hItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1941
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1942 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1943
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1944 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1945 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1946 result = treeselectfunc(tmp->window, tem->itemNew.hItem, (char *)ptrs[0], tmp->data, (void *)ptrs[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1947
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1948 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1949 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1950 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1951 else if(tem->hdr.code == TVN_ITEMEXPANDED && tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1952 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1953 if(tmp->window == tem->hdr.hwndFrom && tem->action == TVE_EXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1954 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1955 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1956
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1957 result = treeexpandfunc(tmp->window, tem->itemNew.hItem, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1958 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1959 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1960 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1961 else if(tem->hdr.code == NM_RCLICK && tmp->message == NM_RCLICK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1962 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1963 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1964 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1965 int (*containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
1966 HTREEITEM hti;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1967 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1968 TVHITTESTINFO thi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1969 void **ptrs = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1970 LONG x, y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1971
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1972 dw_pointer_query_pos(&x, &y);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1973
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1974 thi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1975 thi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1976
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1977 MapWindowPoints(HWND_DESKTOP, tmp->window, &thi.pt, 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1978
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1979 hti = TreeView_HitTest(tmp->window, &thi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1980
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1981 if(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1982 {
1062
28e63fe64167 Minor changes to the tree handling... added the LVIF_PARAM to make sure that member gets filled in on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1060
diff changeset
1983 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1984 tvi.hItem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1985
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1986 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1987 TreeView_SelectItem(tmp->window, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1988
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1989 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1990 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1991 containercontextfunc(tmp->window, ptrs ? (char *)ptrs[0] : NULL, x, y, tmp->data, ptrs ? ptrs[1] : NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1992 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1993 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1994 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1995 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1996 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1997 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1998 if((lem->hdr.code == LVN_ITEMCHANGED && (lem->uChanged & LVIF_STATE)) && tmp->message == TVN_SELCHANGED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1999 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2000 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2001 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2002 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2003 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2004
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2005 iItem = ListView_GetNextItem(tmp->window, -1, LVNI_SELECTED);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2006
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2007 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2008
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2009 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2010 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2011 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2012
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2013 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2014 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2015
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2016 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2017
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2018 /* Seems to be having lParam as 1 which really sucks */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2019 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2020 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2021
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2022 treeselectfunc(tmp->window, 0, (char *)lvi.lParam, tmp->data, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2023 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2024 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2025 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2026 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2027 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2028 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2029 else if(tmp->message == TCN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2030 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2031 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2032 if(tmp->window == tem->hwndFrom && tem->code == tmp->message)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2033 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2034 int (*switchpagefunc)(HWND, unsigned long, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2035 unsigned long num=dw_notebook_page_get(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2036 result = switchpagefunc(tem->hwndFrom, num, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2037 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2038 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2039 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2040 else if(tmp->message == LVN_COLUMNCLICK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2041 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2042 NMLISTVIEW FAR *tem=(NMLISTVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2043 if(tmp->window == tem->hdr.hwndFrom && tem->hdr.code == tmp->message)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2045 int (*columnclickfunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2046 result = columnclickfunc(tem->hdr.hwndFrom, tem->iSubItem, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2047 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2048 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2049 }
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2050 else if(tmp->message == WM_VSCROLL)
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2051 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2052 NMUPDOWN FAR *tem=(NMUPDOWN FAR *)mp2;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2053 if(tmp->window == tem->hdr.hwndFrom && tem->hdr.code == UDN_DELTAPOS)
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2054 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2055 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2056 result = valuechangefunc(tmp->window, tem->iPos + tem->iDelta, tmp->data);
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2057 tmp = NULL;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2058 }
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2059 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2060 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2061 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2062 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2063 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2064 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2065 HWND command;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2066 ULONG passthru = (ULONG)LOWORD(mp1);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2067 ULONG message = (ULONG)HIWORD(mp1);
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2068
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2069 command = (HWND)(uintptr_t)passthru;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2070
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2071 if (message == LBN_SELCHANGE || message == CBN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2072 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2073 int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2074
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2075 if (tmp->message == LBN_SELCHANGE && tmp->window == (HWND)mp2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2076 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2077 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2078 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2079 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2080 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2081 #ifdef TOOLBAR
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2082 else if (message == BN_CLICKED && tmp->message == WM_COMMAND && tmp->window == (HWND)mp2)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2083 {
1760
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2084 TCHAR tmpbuf[100] = {0};
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2085
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2086 GetClassName((HWND)mp2, tmpbuf, 99);
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2087
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2088 /* Make sure this isn't a button, because it will have already been handled */
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2089 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) != 0)
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2090 {
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2091 result = clickfunc(tmp->window, tmp->data);
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2092 tmp = NULL;
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2093 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2094 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2095 #endif
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
2096 else if (tmp->id && passthru == tmp->id)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2097 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2098 HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2099
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2100 if (menuowner == hwndmenu || !menuowner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2101 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2102 _dw_toggle_checkable_menu_item( tmp->window, tmp->id );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2103 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2104 * Call the user supplied callback
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2105 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2106 result = clickfunc((HWND)(uintptr_t)tmp->id, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2107 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2108 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2109 } /* this fires for checkable menu items */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2110 else if ( tmp->window < (HWND)65536 && command == tmp->window && tmp->message != WM_TIMER )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2111 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2112 _dw_toggle_checkable_menu_item( popup ? popup : tmp->window, DW_POINTER_TO_INT(tmp->data) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2113 result = clickfunc(popup ? popup : tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2114 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2115 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2116 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2117 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2118 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2119 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2120 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2121 TCHAR tmpbuf[100] = {0};
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2122 HWND handle = (HWND)mp2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2123 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2124
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2125 if(!GetClassName(handle, tmpbuf, 99))
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2126 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2127 GetClassName(hWnd, tmpbuf, 99);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2128 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2129
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2130 if (_tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2131 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2132
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2133 if (handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2134 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2135 int value = (int)SendMessage(handle, TBM_GETPOS, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2136 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2137 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2138
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2139 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2140 result = valuechangefunc(tmp->window, max - value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2141 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2142 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2143 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2144 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2145 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2146 else if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2147 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2148 if(handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2149 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2150 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2151 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2152
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2153 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2154 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2155 dw_scrollbar_set_pos(tmp->window, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2156 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2157 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2158 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2159 msg = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2160 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2161 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2162 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2163 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2164 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2166 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2167 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2168 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2169 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2170
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2171 /* Now that any handlers are done... do normal processing */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2172 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2173 {
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2174 #ifdef AEROGLASS
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2175 case WM_DWMCOMPOSITIONCHANGED:
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2176 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2177 LONG_PTR styleex = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2178
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2179 if(_DwmIsCompositionEnabled)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2180 _DwmIsCompositionEnabled(&_dw_composition);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2181
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2182 /* If we are no longer compositing... disable layered windows */
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2183 if(!_dw_composition && (styleex & WS_EX_LAYERED))
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2184 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2185 MARGINS mar = {0};
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2186
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2187 SetWindowLongPtr(hWnd, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2188 if(_DwmExtendFrameIntoClientArea)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2189 _DwmExtendFrameIntoClientArea(hWnd, &mar);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2190 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2191 }
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2192 break;
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2193 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2194 #ifdef AEROGLASS1
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2195 case WM_ERASEBKGND:
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2196 if(_dw_composition && (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_LAYERED))
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2197 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2198 static HBRUSH hbrush = 0;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2199 RECT rect;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2200
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2201 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2202 hbrush = CreateSolidBrush(_dw_transparencykey);
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2203
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2204 GetClientRect(hWnd, &rect);
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2205 FillRect((HDC)mp1, &rect, hbrush);
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2206 return TRUE;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2207 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2208 break;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2209 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2210 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2211 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2212 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2213
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2214 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2215 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2216 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2217 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2218 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2219 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2220 static int lastx = -1, lasty = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2221 static HWND lasthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2222
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2223 if(lastx != LOWORD(mp2) || lasty != HIWORD(mp2) || lasthwnd != hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2224 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2225 Box *mybox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2226
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2227 if(mybox && mybox->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2228 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2229 lastx = LOWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2230 lasty = HIWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2231 lasthwnd = hWnd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2233 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2234 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2235 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2236 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2237 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2238 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2239 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2240 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2241 case WM_USER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2242 windowfunc = (void *)mp1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2243
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2244 if(windowfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2245 windowfunc((void *)mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2246 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2247 case WM_USER+5:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2248 _free_menu_data((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2249 DestroyMenu((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2250 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2251 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2252 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2253 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2254
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2255 if(tem->code == TCN_SELCHANGING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2256 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2257 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2258 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2259
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2260 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2261 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2262
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2263 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2264 else if(tem->code == TCN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2265 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2266 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2267 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2268
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2269 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2270 SetParent(array[num]->hwnd, tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2271
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2272 _resize_notebook_page(tem->hwndFrom, num);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2273 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2274 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2275 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2276 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2277 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2278 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2279 HWND handle = (HWND)mp2;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2280 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2281
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2282 if(dw_window_get_data(handle, "_dw_scrollbar"))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2283 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2284 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2285
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2286 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2287 dw_scrollbar_set_pos(handle, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2288 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2289 else
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2290 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2291 TCHAR tmpbuf[100] = {0};
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: 1528
diff changeset
2292
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2293 GetClassName( hWnd, tmpbuf, 99 );
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2294 if ( _tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1 ) == 0 )
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2295 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2296 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2297 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2298 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2299 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2300 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2301 case WM_GETMINMAXINFO:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2302 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2303 MINMAXINFO *info = (MINMAXINFO *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2304 info->ptMinTrackSize.x = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2305 info->ptMinTrackSize.y = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2306 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2307 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2308 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2309 case WM_DESTROY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2310 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2311 HMENU menu = GetMenu(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2312
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2313 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2314 _free_menu_data(menu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2315
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2316 /* Free memory before destroying */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2317 _free_window_memory(hWnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2318 EnumChildWindows(hWnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2319 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2320 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2321 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2322 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2323 HCURSOR cursor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2324
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2325 if((cursor = (HCURSOR)dw_window_get_data(hWnd, "_dw_cursor")) ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2326 (cursor = (HCURSOR)dw_window_get_data(_toplevel_window(hWnd), "_dw_cursor")))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2327 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2328 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2329 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2330 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2331 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2332 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2333 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2334 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2335 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2336 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2337 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2338 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2339 return _colorwndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2340 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2341 if(result != -1)
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2342 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2343 /* Make sure any queued redraws are handled */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2344 _dw_redraw(0, FALSE);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2345 /* Then finally return */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2346 return result;
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2347 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2348 return DefWindowProc(hWnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2349 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2350
461
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2351 VOID CALLBACK _TimerProc(HWND hwnd, UINT msg, UINT_PTR idEvent, DWORD dwTime)
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2352 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2353 _wndproc(hwnd, msg, (WPARAM)idEvent, 0);
461
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2354 }
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2355
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2356 LRESULT CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2357 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2358 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2359 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2360 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2361 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2362 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2363 SetActiveWindow(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2364 SetFocus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2365 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2366 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2367 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2368 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2369 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2370 break;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2371 #ifdef AEROGLASS
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2372 case WM_ERASEBKGND:
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2373 if(_dw_composition && (GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED))
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2374 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2375 static HBRUSH hbrush = 0;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2376 RECT rect;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2377
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2378 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2379 hbrush = CreateSolidBrush(_dw_transparencykey);
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2380
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2381 GetClientRect(hWnd, &rect);
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2382 FillRect((HDC)mp1, &rect, hbrush);
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2383 return TRUE;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2384 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2385 break;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2386 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2387 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2388 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2389 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2390
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2391 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2392 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2393 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2394 HDC hdcPaint = BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2395 int success = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2396
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2397 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2398 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2399 /* Handle foreground */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2400 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2401 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2402 if(thiscinfo->fore != DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2403 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2404 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2405 _green[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2406 _blue[thiscinfo->fore]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2407 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2408 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2409 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2410 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2411 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2412 DW_GREEN_VALUE(thiscinfo->fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2413 DW_BLUE_VALUE(thiscinfo->fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2414 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2415 /* Handle background */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2416 if(thiscinfo->back > -1 && thiscinfo->back < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2417 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2418 if(thiscinfo->back != DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2419 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2420 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2421 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2422 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2423 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2424 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2425 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2426 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2427 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2428 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2429 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2430 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2431 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2432 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2433 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2434 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2435 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2436 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2437 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2438 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2439 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2440 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2441 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2442 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2443 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2444 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2445 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2446 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2447 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2448
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2449 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2450 if(success)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2451 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2452 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2453
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2454 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2455 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2456 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2457 return DefWindowProc(hWnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2458 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2459
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2460 LRESULT CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2461 {
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2462 LRESULT rcode = TRUE;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2463
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2464 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2465 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2466 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2467 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2468 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2469 SetFocus(hWnd);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2470 rcode = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2471 break;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2472 case WM_MOUSEMOVE:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2473 /* call our standard Windows procedure */
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2474 rcode = _wndproc(hWnd, msg, mp1, mp2);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2475 break;
1221
10f5b8645975 Fixes to allow non-toplevel window handles in dw_taskbar_insert() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1214
diff changeset
2476 case WM_USER+2:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2477 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2478 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2479 case WM_RBUTTONUP:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2480 rcode = _wndproc(hWnd, msg, mp1, mp2);
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2481 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2482 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2483 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2484 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2485 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2486 case WM_KEYDOWN:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2487 rcode = _wndproc(hWnd, msg, mp1, mp2);
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2488 break;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2489 default:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2490 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2491 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2492 /* only call the default Windows process if the user hasn't handled the message themselves */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2493 if ( rcode != 0 )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2494 rcode = DefWindowProc(hWnd, msg, mp1, mp2);
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2495 return rcode;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2496 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2497
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2498 LRESULT CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2499 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2500 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2501
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2502 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2503
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2504 if(msg == WM_MOUSEMOVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2505 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2506
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2507 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2508 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2509 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2510 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2511 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2512 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2513 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2514 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2515 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2516 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2517
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2518 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2519 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2520 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2521
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2522 /* Tell the edit control that a buttonpress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2523 * occured and to update it's window title.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2524 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2525 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2526 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2527
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2528 SetTimer(hWnd, 100, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2529
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2530 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2531 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2532 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2533 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2534 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2535 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2536 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2537 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2538 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2539
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2540 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2541 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2542 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2543
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2544 /* Tell the edit control that a buttonpress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2545 * occured and to update it's window title.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2546 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2547 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2548 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2549
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2550 if(hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2551 KillTimer(hWnd, 100);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2552
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2553 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2554 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2555 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2556 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2557 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2558 if(mp1 == 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2559 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2560 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2561
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2562 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2563 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2564
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2565 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2566 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2567 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2568
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2569 /* Tell the edit control that a buttonpress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2570 * occured and to update it's window title.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2571 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2572 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2573 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2574
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2575 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2576 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2577 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2578 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2579 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2580 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2581 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2582 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2583 TCHAR tempbuf[100] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2584 long position;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2585
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2586 GetWindowText(cinfo->buddy, tempbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2587
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2588 position = _tstol(tempbuf);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2589
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
2590 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2591 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2592 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2593 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2594 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2595 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2596
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2597 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2598 return DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2599 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2602 void _click_default(HWND handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2603 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2604 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2605
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2606 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2607
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2608 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2609 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2610 */
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2611 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2612 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2613 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2614 #endif
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2615 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2616 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2617 /* Generate click on default item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2618 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2619
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2620 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2621 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2622 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2623 if (tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2624 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2625 /* Make sure it's the right window, and the right ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2626 if (tmp->window == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2627 {
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2628 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2629 clickfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2630 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2631 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2632 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2633 if (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2634 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2635 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2636 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2637 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2638 SetFocus(handle);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2639 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2640
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2641 /* Subclass function that will handle setting colors on controls */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2642 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2643 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2644 ColorInfo *cinfo;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2645 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2646 WNDPROC pOldProc = 0;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2647 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2648
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2649 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2650
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2651 GetClassName(hWnd, tmpbuf, 99);
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2652 if(_tcsncmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2653 cinfo = &(((Box *)cinfo)->cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2654
1221
10f5b8645975 Fixes to allow non-toplevel window handles in dw_taskbar_insert() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1214
diff changeset
2655 if ( msg == WM_MOUSEMOVE || msg == WM_USER+2 )
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2656 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2657
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2658 if (cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2659 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2660 pOldProc = cinfo->pOldProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2661
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2662 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2663 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2664 case WM_SETFOCUS:
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2665 if(cinfo->combo)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2666 ret = _wndproc(cinfo->combo, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2667 else
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2668 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2669 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2670 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2671 case WM_HSCROLL:
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2672 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2673 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2674 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2675 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2676 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2677 if (hWnd && (mp1 == VK_UP || mp1 == VK_DOWN))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2678 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2679 if (!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2680 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2681 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2682
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2683 /* Tell the spinner control that a keypress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2684 * occured and to update it's internal value.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2685 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2686 if (cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2687 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2688
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2689 if(msg == WM_KEYDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2690 SetTimer(hWnd, 101, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2691 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2692 KillTimer(hWnd, 101);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2693
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2694 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2695 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2696 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2697 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2698 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2699 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2700 if(mp1 == 101)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2701 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2702 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2703 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2704 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2705
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2706 /* Tell the spinner control that a keypress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2707 * occured and to update it's internal value.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2708 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2709 if(cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2710 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2711
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2712 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2713 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2714 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2715 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2716 case WM_CHAR:
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2717 ret = _wndproc(hWnd, msg, mp1, mp2);
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2718 if (ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2719 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2720 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2721 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2722 if (cinfo->combo)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2723 _shift_focus(cinfo->combo, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2724 else if(cinfo->buddy)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2725 _shift_focus(cinfo->buddy, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2726 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2727 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2728 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2729 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2730 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2731 if (cinfo->combo)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2732 _shift_focus(cinfo->combo, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2733 else if(cinfo->buddy)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2734 _shift_focus(cinfo->buddy, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2735 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2736 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2737 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2738 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2739 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2740 else if(LOWORD(mp1) == '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2741 {
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2742
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2743 if ( cinfo->clickdefault )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2744 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2745 _click_default(cinfo->clickdefault);
1846
905f8632005b When handling click default, return instead of running the default handler on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
2746 return (LRESULT)TRUE;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2747 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2748 else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2749 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2750 /*
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2751 * Find the toplevel window for the current window and check if it
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2752 * has a default click set
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2753 */
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2754 HWND tl = _toplevel_window( hWnd );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2755 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA );
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2756 if ( mycinfo && mycinfo->clickdefault )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2757 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2758 _click_default( mycinfo->clickdefault );
1846
905f8632005b When handling click default, return instead of running the default handler on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
2759 return (LRESULT)TRUE;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2760 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2761 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2762 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2763
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2764 /* Tell the spinner control that a keypress has
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2765 * occured and to update it's internal value.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2766 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2767 if (cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2768 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
2769 PostMessage(cinfo->buddy, WM_USER+10, 0, 0);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2770 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2771 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2772 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2773 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2774 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2775 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2776 long val;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2777
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
2778 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2779
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
2780 _sntprintf(tmpbuf, 99, TEXT("%ld"), val);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2781 SetWindowText(hWnd, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2782 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2783 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2784 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2785 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2786 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2787 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2788 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2789 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2790 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2791 case WM_CTLCOLORDLG:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2792 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2793 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2794 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2795 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2796 int thisback = thiscinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2797
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2798 /* Handle foreground */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2799 if(thiscinfo->fore != DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2800 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2801 int fore = _internal_color(thiscinfo->fore);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2802
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2803 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2804 DW_GREEN_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2805 DW_BLUE_VALUE(fore)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2806 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2807 /* Handle background */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2808 if(thiscinfo->back == DW_RGB_TRANSPARENT)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2809 {
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2810 ColorInfo *parentcinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2811
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2812 if(parentcinfo && parentcinfo->back != -1)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2813 thisback = parentcinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2814 }
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2815 if(thisback == DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2816 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2817 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2818
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2819 SetBkColor((HDC)mp1, GetSysColor(COLOR_3DFACE));
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2820
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2821 SelectObject((HDC)mp1, hbr);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2822 return (LONG)(intptr_t)hbr;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2823 }
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2824 else if(thisback != -1 && thisback != DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2825 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2826 int back = _internal_color(thisback);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2827
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2828 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2829 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2830 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2831 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2832 DeleteObject(thiscinfo->hbrush);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2833 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2834 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2835 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2836 SelectObject((HDC)mp1, thiscinfo->hbrush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2837 return (LONG)(intptr_t)thiscinfo->hbrush;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2838 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2839 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2840 #ifdef AEROGLASS
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2841 switch(msg)
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2842 {
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2843 case WM_CTLCOLORSTATIC:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2844 case WM_CTLCOLORBTN:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2845 case WM_CTLCOLORDLG:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2846 {
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2847
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2848 if((_dw_composition && GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED) &&
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2849 (!thiscinfo || (thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2850 {
1518
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2851 if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0)))
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2852 {
1518
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2853 SetBkColor((HDC)mp1, _dw_transparencykey);
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2854 if(thiscinfo->hbrush)
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2855 DeleteObject(thiscinfo->hbrush);
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2856 thiscinfo->hbrush = CreateSolidBrush(_dw_transparencykey);
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2857 SelectObject((HDC)mp1, thiscinfo->hbrush);
bd538277e1e8 Aero Glass fix... instead of trying to draw transparent... use the transparency key as the background color this fixes checboxes/radioboxes and scrolling issues. Seems to have made buttons look better too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1516
diff changeset
2858 return (LONG)thiscinfo->hbrush;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2859 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2860 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2861 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2862 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2863 #endif
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2864 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2865 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2866 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2867 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2868
1132
6d618dcff792 Check that the return code isn't TRUE before passing to handlers on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1131
diff changeset
2869 if(ret != TRUE)
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2870 {
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2871 if(!pOldProc)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2872 return DefWindowProc(hWnd, msg, mp1, mp2);
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2873 return CallWindowProc(pOldProc, hWnd, msg, mp1, mp2);
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2874 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2875 return ret;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2876 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2877
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2878 /* Window procedure for container/listview */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
2879 LRESULT CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2880 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2881 ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2882
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2883 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2884 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2885 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2886 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2887 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2888 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2889 break;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2890 case WM_PAINT:
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2891 if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT))
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2892 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
2893 RECT rectUpd, rectDestin, rectThis, *rect = &rectThis;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2894 int iItems, iTop, i;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2895 COLORREF c;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2896
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2897 /* Load the default background color for the first pass */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2898 ListView_SetTextBkColor(hWnd, continfo->cinfo.back != -1 ? continfo->cinfo.back : ListView_GetBkColor(hWnd));
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2899 /* get the rectangle to be updated */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2900 GetUpdateRect(hWnd, &rectUpd, FALSE);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2901 /* allow default processing first */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2902 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2903 /* number of displayed rows */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2904 iItems = ListView_GetCountPerPage(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2905 /* first visible row */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2906 iTop = ListView_GetTopIndex(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2907
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
2908 for(i=iTop; i<=(iTop+iItems+1); i++)
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2909 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2910 /* if row rectangle intersects update rectangle then it requires re-drawing */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
2911 if(ListView_GetItemRect(hWnd, i, rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, rect))
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2912 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2913 /* change text background colour accordingly */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2914 c = (i % 2) ? continfo->odd : continfo->even;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2915
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2916 if(c != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2917 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2918 ListView_SetTextBkColor(hWnd, c);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2919 /* invalidate the row rectangle then... */
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
2920 InvalidateRect(hWnd, &rectDestin, FALSE);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2921 /* ...force default processing */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2922 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2923 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2924 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2925 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2926 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2927 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2928 case WM_LBUTTONDBLCLK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2929 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2930 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2931 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2932 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2934 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2935 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2936 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2937 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2938 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2939 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2940 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2941 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2942
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2943 if(msg == WM_CHAR && (char)mp1 != '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2944 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2946 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2947
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2948 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2949
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2950 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2951 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2952 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2953 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2954
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2955 ListView_GetItem(hWnd, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2956 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2957
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2958 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2959 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2960
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2961 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2962 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2963 if(tmp->message == NM_DBLCLK && tmp->window == hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2964 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2965 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2966
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2967 /* Seems to be having lParam as 1 which really sucks */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2968 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2969 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2970
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2971 containerselectfunc(tmp->window, (char *)lvi.lParam, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2972 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2973 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2974 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2975 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2976 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2977 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2978 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2979 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2980 case WM_CONTEXTMENU:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2981 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2982 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2983
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2984 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2985 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2986 if(tmp->message == NM_RCLICK && tmp->window == hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2987 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2988 int (*containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2989 LONG x,y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2990 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2991 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2992 LVHITTESTINFO lhi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2993
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2994 dw_pointer_query_pos(&x, &y);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2995
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2996 lhi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2997 lhi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2998
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2999 MapWindowPoints(HWND_DESKTOP, tmp->window, &lhi.pt, 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3000
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3001 iItem = ListView_HitTest(tmp->window, &lhi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3002
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3003 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3004
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3005 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3006 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3007 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3008 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3009
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3010 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3011 ListView_SetSelectionMark(tmp->window, iItem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3012 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3013
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3014 /* Seems to be having lParam as 1 which really sucks */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3015 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3016 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3017
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3018 containercontextfunc(tmp->window, (char *)lvi.lParam, x, y, tmp->data, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3019 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3020 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3021 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3022 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3023 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3024 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3025 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3026 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3027
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3028 if(!continfo || !continfo->cinfo.pOldProc)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3029 return DefWindowProc(hWnd, msg, mp1, mp2);
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3030 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
3033 LRESULT CALLBACK _simplewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3034 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3035 ContainerInfo *cinfo;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3036 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3037
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3038 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3039
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3040 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3041 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3042 case WM_MOUSEMOVE:
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3043 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3044 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3045 case WM_CHAR:
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3046 ret = _wndproc(hWnd, msg, mp1, mp2);
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3047 if(ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3048 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3049 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3050 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3051 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3052 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3053 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3054 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3055 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3056 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3057
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3058 if(ret != TRUE)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3059 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3060 if(!cinfo || !cinfo->cinfo.pOldProc)
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3061 return DefWindowProc(hWnd, msg, mp1, mp2);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3062 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3063 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3064 return ret;
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3065 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3066
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3067 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3068 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3069 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3070
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3071 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3072 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3073 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3074 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3075 Box *tmp = (Box*)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3076 _changebox(tmp, percent, type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3077 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3078 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3079 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3080 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3081 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3082 if(thisbox->items[z].hsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3083 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3084 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3085 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3086 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3087 if(thisbox->items[z].vsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3088 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3089 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3090 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3091 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3094 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3095 {
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: 1448
diff changeset
3096 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
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: 1448
diff changeset
3097 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
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: 1448
diff changeset
3098
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: 1448
diff changeset
3099 ShowWindow(handle1, SW_HIDE);
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: 1448
diff changeset
3100 ShowWindow(handle2, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3101
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3102 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3103 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3104 int newx = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3105 float ratio = (float)percent/(float)100.0;
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3106 Box *tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3107
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3108 newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3109
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3110 MoveWindow(handle1, 0, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3111 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3112
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3113 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3114
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3115 newx = x - newx - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3116
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3117 MoveWindow(handle2, x - newx, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3118 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3119
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3120 dw_window_set_data(hwnd, "_dw_start", DW_INT_TO_POINTER(newx));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3121 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3122 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3123 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3124 int newy = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3125 float ratio = (float)(100.0-percent)/(float)100.0;
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3126 Box *tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3127
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3128 newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3129
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3130 MoveWindow(handle2, 0, y - newy, x, newy, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3131 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3132
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3133 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3134
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3135 newy = y - newy - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3136
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3137 MoveWindow(handle1, 0, 0, x, newy, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3138 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3139
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3140 dw_window_set_data(hwnd, "_dw_start", DW_INT_TO_POINTER(newy));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3141 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3142
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3143 ShowWindow(handle1, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3144 ShowWindow(handle2, SW_SHOW);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3145 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3146
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3147 /* This handles any activity on the scrollbox */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3148 LRESULT CALLBACK _scrollwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3149 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3150 switch (msg)
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3151 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3152 case WM_HSCROLL:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3153 case WM_VSCROLL:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3154 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3155 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3156 SCROLLINFO hsi, vsi, *si = &hsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3157 int bar = SB_HORZ;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3158 int which = LOWORD(mp1);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3159
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3160 /* Initialize the scroll info structs */
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3161 vsi.cbSize = hsi.cbSize = sizeof(SCROLLINFO);
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3162 vsi.fMask = hsi.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3163
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3164 /* Save the current scroll positions */
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3165 GetScrollInfo(hwnd, SB_HORZ, &hsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3166 GetScrollInfo(hwnd, SB_VERT, &vsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3167
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3168 if(msg == WM_VSCROLL)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3169 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3170 bar = SB_VERT;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3171 si = &vsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3172 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3173
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3174 switch(which)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3175 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3176 case SB_THUMBTRACK:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3177 si->nPos = HIWORD(mp1);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3178 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3179 /*case SB_PAGEDOWN:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3180 case SB_PAGELEFT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3181 si->nPos = si->nPos - si->nPage;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3182 if(si->nPos < 0)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3183 si->nPos = 0;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3184 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3185 /*case SB_PAGEUP:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3186 case SB_PAGERIGHT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3187 si->nPos = si->nPos + si->nPage;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3188 if(si->nPos > (int)(si->nMax - si->nPage) + 1)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3189 si->nPos = (si->nMax - si->nPage) + 1;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3190 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3191 /*case SB_LINEDOWN:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3192 case SB_LINELEFT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3193 si->nPos = si->nPos - 1;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3194 if(si->nPos < si->nMin)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3195 si->nPos = si->nMin;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3196 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3197 /*case SB_LINEUP:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3198 case SB_LINERIGHT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3199 si->nPos = si->nPos + 1;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3200 if(si->nPos > (int)(si->nMax - si->nPage) + 1)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3201 si->nPos = (si->nMax - si->nPage) + 1;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3202 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3203 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3204
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3205 /* Position the scrolled box */
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3206 vsi.fMask = hsi.fMask = SIF_POS | SIF_DISABLENOSCROLL;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3207 SetWindowPos(cinfo->combo, 0, -hsi.nPos, -vsi.nPos, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3208 SetScrollInfo(hwnd, bar, si, TRUE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3209 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3210 break;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3211 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3212 return DefWindowProc(hwnd, msg, mp1, mp2);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3213 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3214
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 /* This handles any activity on the splitbars (sizers) */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3216 LRESULT CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3218 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3219 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3220 case WM_ACTIVATE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3221 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3222 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3223
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3224 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3225 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3226 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3227 HDC hdcPaint;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3228 int type = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_type"));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3229 int start = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_start"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3230
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3231 BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3233 if((hdcPaint = GetDC(hwnd)) != NULL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3234 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3235 unsigned long cx, cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3236 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3237 HPEN oldPen = SelectObject(hdcPaint, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3238
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3239 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3240
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3241 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3242 Rectangle(hdcPaint, cx - start - SPLITBAR_WIDTH, 0, cx - start, cy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3243 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3244 Rectangle(hdcPaint, 0, start, cx, start + SPLITBAR_WIDTH);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3245
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3246 SelectObject(hdcPaint, oldBrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3247 DeleteObject(SelectObject(hdcPaint, oldPen));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3248 ReleaseDC(hwnd, hdcPaint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3249 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3250 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3251 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3252 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3253 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3254 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3255 SetCapture(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3256 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3257 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3258 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3259 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3260 if(GetCapture() == hwnd)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3261 ReleaseCapture();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3262 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3263 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3264 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3265 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3266 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3267 int type = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_type"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3268 int start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3269
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3270 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3271 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3272 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3273 SetCursor(LoadCursor(NULL, IDC_SIZENS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3274
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3275 if(GetCapture() == hwnd && percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3276 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3277 POINT point;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3278 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3279 static POINT lastpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3280
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3281 GetCursorPos(&point);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3282 GetWindowRect(hwnd, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3284 if(memcmp(&point, &lastpoint, sizeof(POINT)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3285 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3286 if(PtInRect(&rect, point))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3287 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3288 int width = (rect.right - rect.left);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3289 int height = (rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3290
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3291 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3292 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3293 start = point.x - rect.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3294 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3295 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * (float)100.0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3296 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3297 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3298 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3299 start = point.y - rect.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3300 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3301 *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * (float)100.0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3302 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3303 _handle_splitbar_resize(hwnd, *percent, type, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3304 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3305 memcpy(&lastpoint, &point, sizeof(POINT));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3306 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3307 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3308 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3309 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3310 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3311 return DefWindowProc(hwnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3312 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3313
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3314 /* This handles drawing the status text areas */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3315 LRESULT CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3316 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3317 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3318 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3319 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3320 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3321 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3322 case WM_SETTEXT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3323 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3324 /* Make sure the control redraws when there is a text change */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3325 int ret = (int)DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3326
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3327 InvalidateRgn(hwnd, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3328 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3329 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3330 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3331 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3332 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3333 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3334 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3335 unsigned long cx, cy;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
3336 TCHAR tempbuf[1025] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3337 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3338 HFONT hfont = _acquire_font(hwnd, cinfo ? cinfo->fontname : NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3339 HFONT oldfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3340
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3341 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3342 GetWindowText(hwnd, tempbuf, 1024);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3343
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3344 hdcPaint = BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3345 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3346 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3347 rc.top = rc.left = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3348 rc.right = cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3349 rc.bottom = cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3350 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3351 if(hfont && oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3352 SelectObject(hdcPaint, oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3353 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3354 DeleteObject(hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3355 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3356 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3357 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3358 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3359 return DefWindowProc(hwnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3360 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3361
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3362 #ifdef AEROGLASS
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3363 /* Window procedure to handle drawing themed text when in composited mode */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3364 LRESULT CALLBACK _staticwndproc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3365 {
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3366 ColorInfo *parentcinfo, *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3367 WNDPROC pOldProc;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3368
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3369 if (!cinfo)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3370 return DefWindowProc(hwnd, msg, mp1, mp2);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3371
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3372 /* Need the parent to do the check completely */
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3373 parentcinfo = (ColorInfo *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3374
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3375 /* If we don't require themed drawing */
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3376 if(((cinfo->back != -1 && cinfo->back != DW_RGB_TRANSPARENT) || (parentcinfo && parentcinfo->back != -1))
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3377 || !_dw_composition || !(GetWindowLongPtr(_toplevel_window(hwnd), GWL_EXSTYLE) & WS_EX_LAYERED))
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3378 return _colorwndproc(hwnd, msg, mp1, mp2);
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3379
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3380 pOldProc = cinfo->pOldProc;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3381
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3382 switch(msg)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3383 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3384 case WM_PAINT:
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3385 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3386 PAINTSTRUCT ps;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3387 HDC hdc = BeginPaint(hwnd, &ps);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3388
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3389 if(hdc)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3390 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3391 /* Figure out how to draw */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3392 HDC hdcPaint = NULL;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3393 RECT rcClient;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3394 LONG_PTR dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3395 LONG_PTR dwStyleEx = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3396 HTHEME hTheme = _OpenThemeData(NULL, L"ControlPanelStyle");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3397
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3398 GetClientRect(hwnd, &rcClient);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3399
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3400 if(hTheme)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3401 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3402 /* Create an in memory image to draw to */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3403 HPAINTBUFFER hBufferedPaint = _BeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3404
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3405 if(hdcPaint)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3406 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3407 LONG_PTR dwStaticStyle = dwStyle & 0x1F;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3408 HFONT hFontOld = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3409 int iLen = GetWindowTextLength(hwnd), fore = _internal_color(cinfo->fore);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3410 DTTOPTS DttOpts = { sizeof(DTTOPTS) };
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3411 static HBRUSH hbrush = 0;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3412
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3413 /* Make sure we have a transparency brush */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3414 if(!hbrush)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3415 hbrush = CreateSolidBrush(_dw_transparencykey);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3416
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3417 /* Fill the background with the transparency color */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3418 FillRect(hdcPaint, &rcClient, hbrush);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3419 _BufferedPaintSetAlpha(hBufferedPaint, &ps.rcPaint, 0x00);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3420
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3421 /* Setup how we will draw the text */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3422 DttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3423 DttOpts.crText = cinfo->fore == -1 ? RGB(255, 255, 255) : RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore));
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3424 DttOpts.iGlowSize = 12;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3425
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3426 SetBkMode(hdcPaint, TRANSPARENT);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3427
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3428 if(hFontOld)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3429 hFontOld = (HFONT)SelectObject(hdcPaint, hFontOld);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3430
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3431 /* Make sure there is text to draw */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3432 if(iLen)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3433 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3434 LPWSTR szText = (LPWSTR)_alloca(sizeof(WCHAR)*(iLen+5));
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3435
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3436 if(szText)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3437 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3438 iLen = GetWindowTextW(hwnd, szText, iLen+5);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3439 if(iLen)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3440 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3441 DWORD dwFlags = DT_WORDBREAK;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3442
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3443 switch (dwStaticStyle)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3444 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3445 case SS_CENTER:
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3446 dwFlags |= DT_CENTER;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3447 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3448 case SS_RIGHT:
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3449 dwFlags |= DT_RIGHT;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3450 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3451 case SS_LEFTNOWORDWRAP:
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3452 dwFlags &= ~DT_WORDBREAK;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3453 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3454 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3455
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3456 if(dwStyle & SS_CENTERIMAGE)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3457 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3458 dwFlags |= DT_VCENTER;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3459 dwFlags &= ~DT_WORDBREAK;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3460 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3461
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3462
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3463 if(dwStyle & SS_ENDELLIPSIS)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3464 dwFlags |= DT_END_ELLIPSIS|DT_MODIFYSTRING;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3465 else if(dwStyle & SS_PATHELLIPSIS)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3466 dwFlags |= DT_PATH_ELLIPSIS|DT_MODIFYSTRING;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3467 else if(dwStyle & SS_WORDELLIPSIS)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3468 dwFlags |= DT_WORD_ELLIPSIS|DT_MODIFYSTRING;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3469
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3470 if (dwStyleEx&WS_EX_RIGHT)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3471 dwFlags |= DT_RIGHT;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3472
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3473 if(dwStyle & SS_NOPREFIX)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3474 dwFlags |= DT_NOPREFIX;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3475
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3476 /* Draw the text! */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3477 _DrawThemeTextEx(hTheme, hdcPaint, 0, 0,
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3478 szText, -1, dwFlags, &rcClient, &DttOpts);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3479 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3480 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3481 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3482
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3483 /* Cleanup */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3484 if (hFontOld)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3485 SelectObject(hdcPaint, hFontOld);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3486 _EndBufferedPaint(hBufferedPaint, TRUE);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3487 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3488 _CloseThemeData(hTheme);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3489 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3490 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3491
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3492 EndPaint(hwnd, &ps);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3493 return TRUE;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3494 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3495 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3496 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3497
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3498 if ( !pOldProc )
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3499 return DefWindowProc(hwnd, msg, mp1, mp2);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3500 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3501 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3502 #endif
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3503
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3504 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
3508 LRESULT CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3510 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3511 WNDPROC pOldProc;
1434
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3512 int retval = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3513
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3514 if ( !cinfo )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3515 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3516
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3517 /* We must save a pointer to the old
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3518 * window procedure because if a signal
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3519 * handler attached here destroys this
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3520 * window it will then be invalid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3521 */
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3522 pOldProc = cinfo->pOldProc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3523
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3524 switch(msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3525 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3526 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3527 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3528 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3529 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3530 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3531 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3532 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
3533 return _colorwndproc(hwnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3534 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3535 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3536 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3537 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3538 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3539 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3541 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3542 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3543 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3544 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3545 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3546 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3547
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3548 /* Make sure it's the right window, and the right ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3549 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3550 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3551 int checkbox = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_checkbox"));
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3552
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3553 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3554 in_checkbox_handler = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3555
1434
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3556 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3557
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3558 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3559 in_checkbox_handler = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3560 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3561 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3562 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3563 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3564 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3565 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3566 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3567 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3568 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3569 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3570 /* A button press should also occur for an ENTER or SPACE press
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3571 * while the button has the active input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3572 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3573 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3574 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3575 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3576
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3577 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3578 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3579 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3580 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3581 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3582 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3583
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3584 /* Make sure it's the right window, and the right ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3585 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3586 {
1434
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3587 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3588 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3589 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3590 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3591 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3592 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3593 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3594 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3595 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3596 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3597 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3598 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3599 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3600 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3601 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3602 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3603 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3604 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3605 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3606 if(mp1 == VK_LEFT || mp1 == VK_UP)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3607 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3608 if(mp1 == VK_RIGHT || mp1 == VK_DOWN)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3609 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3610 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3611 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3612
1434
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3613 /* Make sure windows are up-to-date */
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3614 if(retval != -1)
2cca36ec3da6 Fixed automatic redrawing not occurring on OS/2 and Windows when changes were made from a button press handler.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1431
diff changeset
3615 _dw_redraw(0, FALSE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3616 if ( !pOldProc )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3617 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3618 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3619 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3620
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3621 /* This function recalculates a notebook page for example
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3622 * during switching of notebook pages.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3623 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3624 void _resize_notebook_page(HWND handle, int pageid)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3625 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3626 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3627 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3628
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3629 if(array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3630 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3631 Box *box = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3632
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3633 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3634 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3635 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3636 rect.right - rect.left, rect.bottom-rect.top, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3637 if(box && box->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3638 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3639 ShowWindow(box->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3640 _do_resize(box, rect.right - rect.left, rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3641 ShowWindow(box->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3642 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3643
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3644 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3645 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647
759
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
3648 void _create_tooltip(HWND handle, char *text)
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
3649 {
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3650 TOOLINFO ti = { 0 };
1400
ccd383e11ff8 Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1399
diff changeset
3651
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3652 ti.cbSize = sizeof(TOOLINFO);
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3653 ti.hwnd = handle;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3654 ti.hinst = DWInstance;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3655
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3656 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
1397
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3657 if(text)
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3658 {
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3659 /* Set up "tool" information.
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3660 * In this case, the "tool" is the entire parent window.
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3661 */
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3662 ti.uFlags = TTF_SUBCLASS;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
3663 ti.lpszText = UTF8toWide(text);
1403
20c6d0c50c94 Need to make the tooltip rect the max possible control size.. otherwise it might get clipped.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1400
diff changeset
3664 ti.rect.right = ti.rect.bottom = 2000;
1397
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3665
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3666 /* Associate the tooltip with the "tool" window. */
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3667 SendMessage(hwndTooltip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
1397
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3668 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
3669 }
759
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
3670
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
3671 #ifndef GDIPLUS
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3672 /* This function determines the handle for a supplied image filename
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3673 */
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3674 int _dw_get_image_handle(char *filename, HANDLE *icon, HBITMAP *hbitmap)
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3675 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3676 int len, windowtype = 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3677 char *file = malloc(strlen(filename) + 5);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3678
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3679 *hbitmap = 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3680 *icon = 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3681
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3682 if (!file)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3683 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3684 return 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3685 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3686
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3687 strcpy(file, filename);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3688
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3689 /* check if we can read from this file (it exists and read permission) */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3690 if (access(file, 04) == 0)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3691 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3692 len = strlen( file );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3693 if ( len < 4 )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3694 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3695 free(file);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3696 return 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3697 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3698 if ( stricmp( file + len - 4, ".ico" ) == 0 )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3699 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3700 *icon = LoadImage(NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3701 windowtype = BS_ICON;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3702 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3703 else if ( stricmp( file + len - 4, ".bmp" ) == 0 )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3704 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3705 *hbitmap = (HBITMAP)LoadImage(NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3706 windowtype = BS_BITMAP;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3707 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3708 else if ( stricmp( file + len - 4, ".png" ) == 0 )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3709 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3710 *hbitmap = (HBITMAP)LoadImage(NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3711 windowtype = BS_BITMAP;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3712 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3713 free(file);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3714 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3715 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3716 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3717 /* Try with .ico extension first...*/
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3718 strcat(file, ".ico");
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3719 if (access(file, 04) == 0)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3720 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3721 *icon = LoadImage(NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3722 windowtype = BS_ICON;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3723 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3724 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3725 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3726 strcpy(file, filename);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3727 strcat(file, ".bmp");
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3728 if (access(file, 04) == 0)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3729 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3730 *hbitmap = (HBITMAP)LoadImage(NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3731 windowtype = BS_BITMAP;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3732 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3733 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3734 free(file);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3735 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3736 return windowtype;
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3737 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
3738 #endif
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3739
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3740 /* Initialize thread local values to the defaults */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3741 void _init_thread(void)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3742 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3743 COLORREF foreground = RGB(128,128,128);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3744 COLORREF background = DW_RGB_TRANSPARENT;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3745 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3746 ARGB gpfore = MAKEARGB(255, 128, 128, 128);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3747 GpBrush *brush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3748 GpPen *pen;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3749
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3750 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3751 TlsSetValue(_gpPen, (LPVOID)pen);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3752 GdipCreateSolidFill(gpfore, &brush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3753 TlsSetValue(_gpBrush, brush);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3754 #endif
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3755 TlsSetValue(_foreground, DW_UINT_TO_POINTER(foreground));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3756 TlsSetValue(_background, DW_UINT_TO_POINTER(background));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3757 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3758 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3759 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3760
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3767 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3769 WNDCLASS wc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3770 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3771 INITCOMMONCONTROLSEX icc;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3772 char *alttmpdir;
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
3773 #ifdef GDIPLUS
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3774 struct GdiplusStartupInput si;
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
3775 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3776
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3777 /* Setup the private data directory */
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3778 if(argc > 0 && argv[0])
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3779 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3780 char *pos = strrchr(argv[0], '\\');
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3781
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3782 /* Just to be safe try the unix style */
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3783 if(!pos)
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3784 pos = strrchr(argv[0], '/');
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3785
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3786 if(pos)
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3787 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0]));
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3788 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3789 /* If that failed... just get the current directory */
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3790 if(!_dw_exec_dir[0])
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
3791 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir);
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3792
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3793 /* Initialize our thread local storage */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3794 _foreground = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3795 _background = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3796 _hPen = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3797 _hBrush = TlsAlloc();
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3798 #ifdef GDIPLUS
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3799 _gpPen = TlsAlloc();
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3800 _gpBrush = TlsAlloc();
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3801 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3802
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3803 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3804 icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3806 InitCommonControlsEx(&icc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3807
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3808 memset(lookup, 0, sizeof(HICON) * ICON_INDEX_LIMIT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3810 /* Register the generic Dynamic Windows class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3811 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3812 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3813 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3814 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3815 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3816 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3817 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3818 wc.lpszClassName = ClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3819
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3820 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3821
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3822 /* Register the splitbar control */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3823 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3824 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3825 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3826 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3827 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3828 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3829 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3830 wc.lpszClassName = SplitbarClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3831
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3832 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3833
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3834 /* Register the scroller control */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3835 memset(&wc, 0, sizeof(WNDCLASS));
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3836 wc.style = CS_DBLCLKS;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3837 wc.lpfnWndProc = (WNDPROC)_scrollwndproc;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3838 wc.cbClsExtra = 0;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3839 wc.cbWndExtra = 32;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3840 wc.hbrBackground = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3841 wc.lpszMenuName = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3842 wc.lpszClassName = ScrollClassName;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3843
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3844 RegisterClass(&wc);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3845
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3846 /* Register a frame control like on OS/2 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3847 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3848 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3849 wc.lpfnWndProc = (WNDPROC)_framewndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3850 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3851 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3852 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3853 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3854 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3855 wc.lpszClassName = FRAMECLASSNAME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3856
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3857 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3858
1415
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3859 /* Register a status bar control */
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3860 memset(&wc, 0, sizeof(WNDCLASS));
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3861 wc.style = CS_DBLCLKS;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3862 wc.lpfnWndProc = (WNDPROC)_statuswndproc;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3863 wc.cbClsExtra = 0;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3864 wc.cbWndExtra = 32;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3865 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3866 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3867 wc.lpszMenuName = NULL;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3868 wc.lpszClassName = StatusbarClassName;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3869
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3870 RegisterClass(&wc);
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
3871
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3872 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3873 /* Register HTML renderer class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3874 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3875 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3876 wc.lpszClassName = BrowserClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3877 wc.style = CS_HREDRAW|CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3878 RegisterClass(&wc);
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
3879 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3880
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3881 /* Create a set of brushes using the default OS/2 and DOS colors */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3882 for(z=0;z<18;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3883 _colors[z] = CreateSolidBrush(RGB(_red[z],_green[z],_blue[z]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3884
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3885 /* Register an Object Windows class like OS/2 and Win2k+
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3886 * so similar functionality can be used on earlier releases
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3887 * of Windows.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3888 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3889 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3890 wc.style = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3891 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3892 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3893 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3894 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3895 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3896 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3897 wc.lpszClassName = ObjectClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3898
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3899 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3900
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3901 /* Since Windows 95/98/NT don't have a HWND_OBJECT class
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3902 * also known as a input only window, I will create a
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3903 * temporary window that isn't visible and really does nothing
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3904 * except temporarily hold the child windows before they are
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3905 * packed into their correct parent.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3906 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3907
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3908 DW_HWND_OBJECT = CreateWindow(ObjectClassName, TEXT("HWND_OBJECT"), 0, 0, 0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3909 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3910
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3911 if(!DW_HWND_OBJECT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3912 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3913 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError());
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3914 exit(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3915 }
1332
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
3916
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3917 /* Create a tooltip. */
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3918 hwndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3919 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, DW_HWND_OBJECT, NULL, DWInstance,NULL);
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3920
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3921 SetWindowPos(hwndTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
3922
1332
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
3923 /* Create empty box data */
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
3924 SetWindowLongPtr(DW_HWND_OBJECT, GWLP_USERDATA, (LONG_PTR)calloc(sizeof(Box), 1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3926 /* We need the version to check capability like up-down controls */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3927 dwVersion = GetVersion();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3928 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3929
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3930 /* Initialize Security for named events and memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3931 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3932 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3934 OleInitialize(NULL);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
3935
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3936 /*
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3937 * Get an alternate temporary directory in case TMP doesn't exist
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3938 */
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3939 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL )
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3940 {
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3941 strcpy( _dw_alternate_temp_dir, "c:\\tmp" );
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3942 }
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3943 else
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3944 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
3945 strncpy( _dw_alternate_temp_dir, alttmpdir, MAX_PATH );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3946 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3947
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3948 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3949 /* Setup GDI+ */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3950 si.GdiplusVersion = 1;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3951 si.DebugEventCallback = NULL;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3952 si.SuppressBackgroundThread = FALSE;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3953 si.SuppressExternalCodecs = FALSE;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3954 GdiplusStartup(&gdiplusToken, &si, NULL);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3955 #endif
1628
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3956
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3957 /* GDI+ Needs to be initialized before calling _init_thread(); */
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3958 _init_thread();
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3959
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3960 if((huxtheme = LoadLibrary(TEXT("uxtheme"))))
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3961 _SetWindowTheme = (HRESULT (WINAPI *)(HWND, LPCWSTR, LPCWSTR ))GetProcAddress(huxtheme, "SetWindowTheme");
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3962 #ifdef AEROGLASS
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3963 /* Attempt to load the Desktop Window Manager and Theme library */
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3964 if(huxtheme && (hdwm = LoadLibrary(TEXT("dwmapi"))))
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
3965 {
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3966 _DwmExtendFrameIntoClientArea = (HRESULT (WINAPI *)(HWND, const MARGINS *))GetProcAddress(hdwm, "DwmExtendFrameIntoClientArea");
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
3967 if((_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL *))GetProcAddress(hdwm, "DwmIsCompositionEnabled")))
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
3968 _DwmIsCompositionEnabled(&_dw_composition);
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3969 _OpenThemeData = (HTHEME (WINAPI *)(HWND, LPCWSTR))GetProcAddress(huxtheme, "OpenThemeData");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3970 _BeginBufferedPaint = (HPAINTBUFFER (WINAPI *)(HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, HDC *))GetProcAddress(huxtheme, "BeginBufferedPaint");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3971 _BufferedPaintSetAlpha = (HRESULT (WINAPI *)(HPAINTBUFFER, const RECT *, BYTE))GetProcAddress(huxtheme, "BufferedPaintSetAlpha");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3972 _DrawThemeTextEx = (HRESULT (WINAPI *)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const DTTOPTS *))GetProcAddress(huxtheme, "DrawThemeTextEx");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3973 _EndBufferedPaint = (HRESULT (WINAPI *)(HPAINTBUFFER, BOOL))GetProcAddress(huxtheme, "EndBufferedPaint");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3974 _CloseThemeData = (HRESULT (WINAPI *)(HTHEME))GetProcAddress(huxtheme, "CloseThemeData");
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3975 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3976 /* In case of error close the library if needed */
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3977 else if(hdwm)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3978 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3979 FreeLibrary(hdwm);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3980 hdwm = 0;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3981 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3982 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3983 #ifdef RICHEDIT
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3984 /* Attempt to load rich edit library */
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3985 if(!(hrichedit = LoadLibrary("riched20")))
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3986 hrichedit = LoadLibrary("riched32");
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3987 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3988 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
3991 static int _dw_main_running = FALSE;
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
3992
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 * Runs a message loop for Dynamic Windows.
150
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
3995 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3996 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3998 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3999
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4000 _dwtid = 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: 1448
diff changeset
4001 /* 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: 1448
diff changeset
4002 _dw_redraw(0, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4003
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4004 /* Set the running flag to TRUE */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4005 _dw_main_running = TRUE;
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4006
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4007 /* Run the loop until the flag is unset... or error */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4008 while(_dw_main_running && GetMessage(&msg, NULL, 0, 0))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4009 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4010 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4011 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4012 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4013 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4014 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4015 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4016 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4017 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4021 * 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: 1521
diff changeset
4022 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4023 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: 1521
diff changeset
4024 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4025 _dw_main_running = FALSE;
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4026 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4027
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4028 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4029 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4030 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4031 * milliseconds: Number of milliseconds to run the loop for.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4032 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4033 void API dw_main_sleep(int milliseconds)
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4034 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4035 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4036 double start = (double)clock();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4037
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4038 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4039 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4040 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4041 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4042 GetMessage(&msg, NULL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4043 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4044 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4045 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4046 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4047 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4048 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4049 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4050 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4051 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4052 Sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4053 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4054 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4055
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4056 /*
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4057 * Processes a single message iteration and returns.
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4058 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4059 void API dw_main_iteration(void)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4060 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4061 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4062
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4063 _dwtid = dw_thread_id();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4064
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4065 if(GetMessage(&msg, NULL, 0, 0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4066 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4067 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4068 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4069 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4070 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4071 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4072 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4073 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4074 }
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4075 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4076
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4077 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4081 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4083 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4085 free(ptr);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4093 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4095 DWDialog *tmp = malloc(sizeof(DWDialog));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4096
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4097 tmp->eve = dw_event_new();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4098 dw_event_reset(tmp->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4099 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4100 tmp->done = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4101 tmp->result = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4113 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4115 dialog->result = result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4116 dw_event_post(dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4117 dialog->done = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4118 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4127 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4129 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4130 void *tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4131
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4132 while (GetMessage(&msg,NULL,0,0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4133 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4134 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4135 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4136 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4137 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4138 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4139 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4140 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4141 if(dialog->done)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4142 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4143 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4144 dw_event_close(&dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4145 tmp = dialog->result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4146 free(dialog);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4147 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 /*
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4151 * 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: 1305
diff changeset
4152 * Parameters:
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4153 * 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: 1305
diff changeset
4154 * ...: 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: 1305
diff changeset
4155 */
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4156 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: 1305
diff changeset
4157 {
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4158 va_list args;
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4159 char outbuf[1025] = {0}, *thisbuf = outbuf;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4160
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4161 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: 1305
diff changeset
4162 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: 1305
diff changeset
4163 va_end(args);
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4164
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4165 OutputDebugString(UTF8toWide(thisbuf));
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4166 }
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4167
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4168 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 389
diff changeset
4175 int API dw_messagebox(char *title, int flags, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4177 va_list args;
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4178 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4179 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4180
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4181 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: 1305
diff changeset
4182 vsnprintf(outbuf, 1024, format, args);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4183 va_end(args);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4184
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4185 rc = MessageBox(HWND_DESKTOP, UTF8toWide(thisbuf), UTF8toWide(title), flags);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4186 if(rc == IDOK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4187 return DW_MB_RETURN_OK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4188 else if(rc == IDYES)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4189 return DW_MB_RETURN_YES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4190 else if(rc == IDNO)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4191 return DW_MB_RETURN_NO;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4192 else if(rc == IDCANCEL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4193 return DW_MB_RETURN_CANCEL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4194 else return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4198 * Minimizes or Iconifies a top-level window.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4199 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4200 * handle: The window handle to minimize.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4201 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4202 int API dw_window_minimize(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4203 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4204 return ShowWindow(handle, SW_MINIMIZE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4205 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4206
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4207 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4208 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4209 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4210 * handle: The window handle to make topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4211 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4212 int API dw_window_raise(HWND handle)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4213 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4214 return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4215 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4216
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4217 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4218 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4219 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4220 * handle: The window handle to make bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4221 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4222 int API dw_window_lower(HWND handle)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4223 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4224 return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4225 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4226
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4227 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4232 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 {
1487
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4234 int rc;
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4235 RECT rect;
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4236
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4237 GetClientRect(handle, &rect);
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4238
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4239 /* If the client area is 0x0 then call the autosize routine */
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4240 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0)
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4241 dw_window_set_size(handle, 0, 0);
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4242
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4243 rc = ShowWindow(handle, SW_SHOW);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4244 SetFocus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4245 _initial_focus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4246 return rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4254 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4256 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4264 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 {
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4266 HWND parent;
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4267 HMENU menu;
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4268
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4269 /* Handle special case for menu handle */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4270 if(handle < (HWND)65536)
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4271 {
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4272 char buffer[31] = {0};
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
4273 ULONG id = (ULONG)(uintptr_t)handle;
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4274
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4275 _snprintf(buffer, 30, "_dw_id%ld", id);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4276 menu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4277
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4278 if(menu && IsMenu(menu))
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4279 return dw_menu_delete_item((HMENUI)menu, id);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4280 return DW_ERROR_UNKNOWN;
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4281 }
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4282
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4283 parent = GetParent(handle);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4284 menu = GetMenu(handle);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4285
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
4286 if(menu)
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
4287 _free_menu_data(menu);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4288
1332
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
4289 /* If it is a desktop window let WM_DESTROY handle it */
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
4290 if(parent != HWND_DESKTOP)
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
4291 {
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1766
diff changeset
4292 dw_box_unpack(handle);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4293 _free_window_memory(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4294 EnumChildWindows(handle, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4295 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4296 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4299 /* Causes entire window to be invalidated and redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4300 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4301 * handle: Toplevel window handle to be redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4302 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4303 void API dw_window_redraw(HWND handle)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4304 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4305 Box *mybox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4306
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4307 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4308 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4309 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4310 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4311
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4312 GetClientRect(handle, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4313
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4314 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4315 _do_resize(mybox, rect.right - rect.left, rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4316 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4317 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4318 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4319
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4326 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4328 SetParent(handle, newparent);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4329 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4330
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4331 LOGFONT _get_logfont(HDC hdc, char *fontname)
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4332 {
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4333 char *Italic, *Bold, *myFontName = strchr(fontname, '.');
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4334 int size = atoi(fontname);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4335 LOGFONT lf = {0};
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4336
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4337 /* If we found a '.' use the location after the . */
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4338 if(myFontName)
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4339 myFontName = _strdup(++myFontName);
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4340 else /* Otherwise use the whole fontname and default size of 9 */
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4341 myFontName = _strdup(fontname);
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4342
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4343 lf.lfHeight = -MulDiv(size ? size : 9, GetDeviceCaps(hdc, LOGPIXELSY), 72);
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4344 Italic = strstr(myFontName, " Italic");
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4345 Bold = strstr(myFontName, " Bold");
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4346 lf.lfWidth = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4347 lf.lfEscapement = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4348 lf.lfOrientation = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4349 lf.lfItalic = Italic ? TRUE : FALSE;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4350 lf.lfUnderline = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4351 lf.lfStrikeOut = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4352 lf.lfWeight = Bold ? FW_BOLD : FW_NORMAL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4353 lf.lfCharSet = DEFAULT_CHARSET;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4354 lf.lfOutPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4355 lf.lfClipPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4356 lf.lfQuality = DEFAULT_QUALITY;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4357 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4358 if(Italic)
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4359 *Italic = 0;
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4360 if(Bold)
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4361 *Bold = 0;
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4362 _tcsncpy(lf.lfFaceName, UTF8toWide(myFontName), (sizeof(lf.lfFaceName)/sizeof(TCHAR))-1);
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4363 free(myFontName);
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4364 return lf;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4365 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4366
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: 1073
diff changeset
4367 /* Create a duplicate of an existing font handle
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: 1073
diff changeset
4368 * that is safe to call DeleteObject() on.
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: 1073
diff changeset
4369 */
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: 1073
diff changeset
4370 HFONT _DupFontHandle(HFONT hfont)
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: 1073
diff changeset
4371 {
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: 1073
diff changeset
4372 LOGFONT lf = {0};
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: 1073
diff changeset
4373 return GetObject(hfont, sizeof(lf), &lf) ? CreateFontIndirect(&lf) : NULL;
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: 1073
diff changeset
4374 }
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: 1073
diff changeset
4375
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: 1073
diff changeset
4376 /* Create a font handle from specified font name..
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: 1073
diff changeset
4377 * or return a handle to the default font.
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: 1073
diff changeset
4378 */
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4379 HFONT _acquire_font2(HDC hdc, char *fontname)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4380 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4381 HFONT hfont = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4382
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4383 if(fontname != DefaultFont && fontname[0])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4384 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4385 LOGFONT lf = _get_logfont(hdc, fontname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4386 hfont = CreateFontIndirect(&lf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4387 }
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: 1073
diff changeset
4388 if(!hfont && _DefaultFont)
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: 1073
diff changeset
4389 hfont = _DupFontHandle(_DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4390 if(!hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4391 hfont = GetStockObject(DEFAULT_GUI_FONT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4392 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4395 /* Create a font handle from specified font name..
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4396 * or return a handle to the default font.
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4397 */
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4398 HFONT _acquire_font(HWND handle, char *fontname)
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4399 {
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4400 HDC hdc = GetDC(handle);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4401 HFONT hfont = _acquire_font2(hdc, fontname);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4402 ReleaseDC(handle, hdc);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4403 return hfont;
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4404 }
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4405
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 /*
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: 1073
diff changeset
4407 * 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: 1073
diff changeset
4408 * 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: 1073
diff changeset
4409 * 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: 1073
diff changeset
4410 */
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: 1073
diff changeset
4411 void API dw_font_set_default(char *fontname)
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: 1073
diff changeset
4412 {
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: 1073
diff changeset
4413 HFONT oldfont = _DefaultFont;
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4414
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: 1073
diff changeset
4415 _DefaultFont = _acquire_font(HWND_DESKTOP, fontname);
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: 1073
diff changeset
4416 if(oldfont)
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: 1073
diff changeset
4417 {
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: 1073
diff changeset
4418 DeleteObject(oldfont);
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: 1073
diff changeset
4419 }
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: 1073
diff changeset
4420 }
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: 1073
diff changeset
4421
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4422 /* Internal function to return a pointer to an item struct
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4423 * with information about the packing information regarding object.
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4424 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4425 Item *_box_item(HWND handle)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4426 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4427 HWND parent = GetParent(handle);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4428 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4429
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4430 /* If it is a desktop window let WM_DESTROY handle it */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4431 if(parent != HWND_DESKTOP)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4432 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4433 if(thisbox && thisbox->count)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4434 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4435 int z;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4436 Item *thisitem = thisbox->items;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4437
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4438 for(z=0;z<thisbox->count;z++)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4439 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4440 if(thisitem[z].hwnd == handle)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4441 return &thisitem[z];
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4442 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4443 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4444 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4445 return NULL;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4446 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4447
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4448 /* Internal function to calculate the widget's required size..
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4449 * These are the general rules for widget sizes:
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4450 *
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4451 * 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: 1550
diff changeset
4452 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4453 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4454 * Spinbutton: 50x(maxfontheight)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4455 * 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: 1415
diff changeset
4456 * 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: 1415
diff changeset
4457 * Buttons/Bitmaps: Size of text or image and border.
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4458 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4459 void _control_size(HWND handle, int *width, int *height)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4460 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4461 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4462 TCHAR tmpbuf[100] = {0};
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4463 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4464 HBITMAP hbm = 0;
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4465 HICON hic = 0;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4466 ICONINFO ii = {0};
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4467
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4468 GetClassName(handle, tmpbuf, 99);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4469
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4470 /* Attempt to get icon from classes that can have them */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4471 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4472 hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4473 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4474 hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4475
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4476 /* If we got an icon, pull out the internal bitmap */
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4477 if(hic)
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4478 {
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4479 if(GetIconInfo(hic, &ii))
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4480 hbm = ii.hbmMask ? ii.hbmMask : ii.hbmColor;
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4481 }
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4482
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4483 /* If we weren't able to get the bitmap from the icon... */
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4484 if(!hbm)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4485 {
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4486 /* Attempt to get bitmap from classes that can have them */
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4487 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4488 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4489 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4490 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4491 }
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4492
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4493 /* If we got an image... set the sizes appropriately */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4494 if(hbm)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4495 {
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4496 BITMAP bmi = { 0 };
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4497
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4498 GetObject(hbm, sizeof(BITMAP), &bmi);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4499 thiswidth = bmi.bmWidth;
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4500 thisheight = bmi.bmHeight;
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4501 }
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4502 else
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4503 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4504 char *buf = dw_window_get_text(handle);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4505
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4506 /* If we have a string...
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4507 * calculate the size with the current font.
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4508 */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4509 if(buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4510 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4511 if(*buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4512 dw_font_text_extents_get(handle, NULL, buf, &thiswidth, &thisheight);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4513 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0 ||
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4514 _tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1) == 0)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4515 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4516 dw_free(buf);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4517 }
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4518 }
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4519
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4520 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4521 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0)
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4522 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4523 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4524 thiswidth = 150;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4525 extraheight = 4;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4526 if(thisheight < 18)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4527 thisheight = 18;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4528 }
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4529 /* Ranged: Percent, Slider, Scrollbar */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4530 else if(_tcsnicmp(tmpbuf, PROGRESS_CLASS, _tcslen(PROGRESS_CLASS)+1) == 0 ||
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4531 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1) == 0 ||
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4532 _tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4533 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4534 if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0 &&
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4535 GetWindowLong(handle, GWL_STYLE) & SBS_VERT)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4536 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4537 /* Vertical */
1445
8f7692fcad37 Use system metrics/values to get the scrollbar sizes on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1443
diff changeset
4538 thiswidth = GetSystemMetrics(SM_CXVSCROLL);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4539 thisheight = 100;
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4540 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4541 else
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4542 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4543 /* Horizontal */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4544 thiswidth = 100;
1445
8f7692fcad37 Use system metrics/values to get the scrollbar sizes on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1443
diff changeset
4545 thisheight = GetSystemMetrics(SM_CYHSCROLL);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4546 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4547 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4548 /* Spinbuttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4549 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0)
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4550 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4551 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4552 thiswidth = 50;
1456
6bf5dc7da45d Added automatic widget size detection a variety of places in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1454
diff changeset
4553 extraheight = 6;
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4554 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4555 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4556 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4557 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4558 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4559 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4560 int minsize = 24;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4561
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4562 if(imlist)
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4563 ImageList_GetIconSize(imlist, &thiswidth, &thisheight);
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4564
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4565 /* If we are flat the size can be smaller */
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4566 if(GetWindowLong(handle, GWL_STYLE) & TBSTYLE_FLAT)
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4567 minsize = 20;
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4568 else
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4569 {
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4570 thiswidth += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4571 thisheight += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4572 }
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4573
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4574 if(thiswidth < minsize)
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4575 thiswidth = minsize;
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4576 if(thisheight < minsize)
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4577 thisheight = minsize;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4578 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4579 #endif
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4580 /* Listbox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4581 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0)
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4582 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4583 char buf[1025] = {0};
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4584 int x, count = dw_listbox_count(handle);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4585 int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4586
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4587 thisheight = 8;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4588
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4589 for(x=0;x<count;x++)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4590 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4591 int height, width = 0;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4592
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4593 dw_listbox_get_text(handle, x, buf, 1024);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4594
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4595 if(strlen(buf))
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4596 dw_font_text_extents_get(handle, NULL, buf, &width, &height);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4597 else
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4598 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4599
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4600 width += basicwidth;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4601
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4602 if(width > thiswidth)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4603 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4604 thisheight += height;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4605 }
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4606
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4607 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4608 thiswidth = _DW_SCROLLED_MIN_WIDTH;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4609 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4610 thisheight = _DW_SCROLLED_MIN_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4611 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4612 thisheight = _DW_SCROLLED_MAX_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4613 }
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4614 /* Entryfields and MLE */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4615 else if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1) == 0 ||
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4616 _tcsnicmp(tmpbuf, RICHEDIT_CLASS, _tcslen(RICHEDIT_CLASS)+1) == 0)
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4617 {
1541
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4618 LONG style = GetWindowLong(handle, GWL_STYLE);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4619 if((style & ES_MULTILINE))
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4620 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4621 unsigned long bytes;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4622 int height, width;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4623 char *buf, *ptr;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4624 int basicwidth;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4625
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4626 if(style & ES_AUTOHSCROLL)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4627 thisheight = GetSystemMetrics(SM_CYHSCROLL) + 8;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4628 else
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4629 thisheight = 8;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4630 basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4631
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4632 dw_mle_get_size(handle, &bytes, NULL);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4633
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4634 ptr = buf = _alloca(bytes + 2);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4635 dw_mle_export(handle, buf, 0, (int)bytes);
1561
46e34bd92336 Implemented guessing size of MLE on GTK... not as accurate as the other platforms...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1556
diff changeset
4636 buf[bytes] = 0;
1541
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4637 strcat(buf, "\n");
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4638
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4639 /* MLE */
1581
a80ec948c3eb Fixed a MinGW warning and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1570
diff changeset
4640 while((ptr = strstr(buf, "\n")))
1541
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4641 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4642 ptr[0] = 0;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4643 width = 0;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4644 if(strlen(buf))
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4645 dw_font_text_extents_get(handle, NULL, buf, &width, &height);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4646 else
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4647 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4648
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4649 width += basicwidth;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4650
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4651 if(!(style & ES_AUTOHSCROLL) && width > _DW_SCROLLED_MAX_WIDTH)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4652 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4653 thiswidth = _DW_SCROLLED_MAX_WIDTH;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4654 thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH);
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4655 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4656 else
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4657 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4658 if(width > thiswidth)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4659 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4660 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4661 thisheight += height;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4662 buf = &ptr[1];
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4663 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4664
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4665 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4666 thiswidth = _DW_SCROLLED_MIN_WIDTH;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4667 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4668 thisheight = _DW_SCROLLED_MIN_HEIGHT;
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4669 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4670 thisheight = _DW_SCROLLED_MAX_HEIGHT;
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4671 }
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4672 else
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4673 {
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4674 /* Entryfield */
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4675 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4676 thiswidth = 150;
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4677 extraheight = 6;
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4678 }
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4679 }
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4680 /* Container */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4681 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0)
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4682 {
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4683 DWORD result = ListView_ApproximateViewRect(handle, _DW_SCROLLED_MAX_WIDTH, _DW_SCROLLED_MAX_HEIGHT, -1);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4684
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4685 thiswidth = LOWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4686 thisheight = HIWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4687
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4688 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4689 thiswidth = _DW_SCROLLED_MAX_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4690 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4691 thiswidth = _DW_SCROLLED_MIN_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4692 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4693 thisheight = _DW_SCROLLED_MIN_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4694 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4695 thisheight = _DW_SCROLLED_MAX_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4696 }
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4697 /* Tree */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4698 else if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0)
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4699 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
4700 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: 1561
diff changeset
4701 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2);
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4702 }
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4703 /* Buttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4704 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4705 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4706 ULONG style = GetWindowLong(handle, GWL_STYLE);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4707
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4708 /* Bitmap buttons */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4709 if(hbm)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4710 {
1431
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4711 extrawidth = 5;
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4712 extraheight = 5;
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4713 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4714 /* Checkbox or radio button */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4715 else if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON)
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4716 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4717 extrawidth = 24;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4718 extraheight = 4;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4719 }
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4720 /* Text buttons */
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4721 else
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4722 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4723 extrawidth = 8;
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4724 extraheight = 8;
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4725 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4726 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4727 else if(_tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1) == 0)
1415
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
4728 {
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
4729 extrawidth = 4;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
4730 extraheight = 2;
ddf9cfb4a074 Add unique status bar class on Windows so we can identify it when calculating control sizes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1411
diff changeset
4731 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4732
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4733 /* Set the requested sizes */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4734 if(width)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4735 *width = thiswidth + extrawidth;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4736 if(height)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4737 *height = thisheight + extraheight;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4738
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4739 /* Free temporary bitmaps */
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4740 if(ii.hbmColor)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4741 DeleteObject(ii.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4742 if(ii.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4743 DeleteObject(ii.hbmMask);
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4744 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4745
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: 1073
diff changeset
4746 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4752 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 {
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4754 HFONT hfont, oldfont;
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4755 ColorInfo *cinfo;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4756 TCHAR tmpbuf[100] = {0};
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4757
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4758 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4759
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4760 GetClassName(handle, tmpbuf, 99);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4761 if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 )
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4762 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4763 /* groupbox */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4764 Box *thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4765 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4766 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4767 handle = thisbox->grouphwnd;
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4768 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4769 }
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4770
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4771 /* This needs to be after we get the correct handle */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4772 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4773 hfont = _acquire_font(handle, fontname);
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4774
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4775 if(hfont && fontname)
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4776 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4777 if(cinfo)
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4778 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4779 strcpy(cinfo->fontname, fontname);
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4780 if(!oldfont)
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4781 oldfont = cinfo->hfont;
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4782 cinfo->hfont = hfont;
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4783 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4784 else
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4785 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4786 cinfo = calloc(1, sizeof(ColorInfo));
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4787 cinfo->fore = cinfo->back = -1;
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4788
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4789 strncpy(cinfo->fontname, fontname, 127);
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4790
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4791 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4792 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4793 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4794 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4795 /* If we changed the font... */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4796 if(hfont)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4797 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4798 Item *item = _box_item(handle);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4799
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4800 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4801 if(oldfont)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4802 DeleteObject(oldfont);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4803
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4804 /* Check to see if any of the sizes need to be recalculated */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4805 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: 1415
diff changeset
4806 {
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4807 _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: 1415
diff changeset
4808 /* 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: 1415
diff changeset
4809 _dw_redraw(_toplevel_window(handle), TRUE);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4810 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4811 return DW_ERROR_NONE;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4812 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4813 return DW_ERROR_UNKNOWN;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4816 /* 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: 1042
diff changeset
4817 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4818 * currfont: current font
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4819 * Returns:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4820 * A malloced buffer with the selected font or NULL on error.
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4821 */
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4822 char * API dw_font_choose(char *currfont)
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4823 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4824 CHOOSEFONT cf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4825 LOGFONT lf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4826 char *str = NULL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4827 char *bold = "";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4828 char *italic = "";
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4829
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4830 if(currfont && *currfont)
1060
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4831 lf = _get_logfont(NULL, currfont);
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4832
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4833 cf.lStructSize = sizeof(cf);
1059
2f79f183ff03 Windows was missing the flag to load the font from the LOGFONT struct when creating the font chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1051
diff changeset
4834 cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4835 cf.lpLogFont = &lf;
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4836
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4837 if(ChooseFont(&cf))
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4838 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4839 str = (char *)calloc( 101, 1 );
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4840 if ( str )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4841 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4842 int height;
1060
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4843 HDC hdc = GetDC(NULL);
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4844
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4845 if ( lf.lfWeight > FW_MEDIUM )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4846 bold = " Bold";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4847 if ( lf.lfItalic )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4848 italic = " Italic";
1060
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4849 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY));
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4850 ReleaseDC(NULL, hdc);
1643
08da4840dfc3 Need to convert to UTF8 in dw_font_choose() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1641
diff changeset
4851 _snprintf( str, 100, "%d.%s%s%s", height, WideToUTF8(lf.lfFaceName), bold, italic );
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4852 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4853 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4854 return str;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4855 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4856
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 /*
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4858 * Gets the font used by a specified window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4859 * Parameters:
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4860 * handle: The window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4861 * fontname: Name and size of the font in the form "size.fontname"
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4862 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4863 char * API dw_window_get_font(HWND handle)
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4864 {
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4865 HFONT oldfont = NULL;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4866 char *str = NULL;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4867 char *bold = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4868 char *italic = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4869 LOGFONT lf = { 0 };
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4870 Box *thisbox;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4871 TCHAR tmpbuf[100] = {0};
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4872
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4873 GetClassName(handle, tmpbuf, 99);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4874 if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 )
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4875 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4876 /* groupbox */
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4877 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4878 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4879 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4880 handle = thisbox->grouphwnd;
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4881 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4882 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4883 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4884 if ( GetObject( oldfont, sizeof(lf), &lf ) )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4885 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4886 str = (char *)calloc( 100, 1 );
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4887 if ( str )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4888 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4889 int height;
1060
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4890 HDC hdc = GetDC(handle);
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4891
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4892 if ( lf.lfWeight > FW_MEDIUM )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4893 bold = " Bold";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4894 if ( lf.lfItalic )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4895 italic = " Italic";
1060
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4896 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY));
efa7d527adea Use the actual Windows point size for a device... doing conversion as necessary.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1059
diff changeset
4897 ReleaseDC(handle, hdc);
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4898 _snprintf( str, 100, "%d.%s%s%s", height, lf.lfFaceName, bold, italic );
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4899 }
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4900 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4901 if ( oldfont )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4902 DeleteObject( oldfont );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4903 return str;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4904 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4905
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4906 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 * handle: The window (widget) handle.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4910 * fore: Foreground color in RGB format.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4911 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4913 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4915 ColorInfo *cinfo;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4916 Box *thisbox;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4917 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4918
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4919 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4920
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4921 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4922
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4923 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW))==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4924 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
4925 cinfo->fore = fore = _internal_color(fore);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
4926 cinfo->back = back = _internal_color(back);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4928 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4929 DW_GREEN_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4930 DW_BLUE_VALUE(fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4931 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4932 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4933 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4934 ListView_SetBkColor(handle, RGB(DW_RED_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4935 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4936 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4937 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4938 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4939 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4940 else if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)) == 0 )
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4941 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4942 /* groupbox */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4943 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4944 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4945 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4946 thisbox->cinfo.fore = fore;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4947 thisbox->cinfo.back = back;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4948 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4949 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4951 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4952 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4953 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4954 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4955 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4956 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4957 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4958 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4959
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4960 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4961 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4962
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4963 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4964 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4965 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4966 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4967 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4976 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4978 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4986 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4988 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4994 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4996 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5000 * Changes the appearance of the mouse pointer.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5001 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5002 * handle: Handle to widget for which to change.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5003 * cursortype: ID of the pointer you want.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5004 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
5005 void API dw_window_set_pointer(HWND handle, int pointertype)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5006 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5007 HCURSOR cursor = pointertype < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) : (HCURSOR)(intptr_t)pointertype;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5008
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5009 if(!pointertype)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5010 dw_window_set_data(handle, "_dw_cursor", 0);
531
79696a852401 Added DW_POINTER_DEFAULT, this will return the pointer to the default
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 527
diff changeset
5011 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5012 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5013 dw_window_set_data(handle, "_dw_cursor", DW_POINTER(cursor));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5014 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5015 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5016 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5017
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5018 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 * title: The Window title.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5023 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5025 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5027 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5028 Box *newbox = calloc(sizeof(Box), 1);
926
4519a1d2525e Reverting that last change... it makes resizing really nice but all sorts of other things screw up.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 925
diff changeset
5029 ULONG flStyleEx = 0;
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5030 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5031 MARGINS mar = {-1};
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5032
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5033 if(_dw_composition && (flStyle & DW_FCF_COMPOSITED))
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5034 flStyleEx = WS_EX_LAYERED;
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5035 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5036
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5037 newbox->type = DW_VERT;
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: 1436
diff changeset
5038 newbox->vsize = newbox->hsize = SIZEEXPAND;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5039 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5040
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5041 if(!(flStyle & WS_CAPTION))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5042 flStyle |= WS_POPUPWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5043
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5044 if(flStyle & DW_FCF_TASKLIST ||
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5045 flStyle & WS_VSCROLL /* This is deprecated and should go away in version 3? */)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5046 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5047 hwndframe = CreateWindowEx(flStyleEx, ClassName, UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffdf0000, CW_USEDEFAULT, CW_USEDEFAULT,
1487
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
5048 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5049 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5050 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5051 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5052 flStyleEx |= WS_EX_TOOLWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5053
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5054 hwndframe = CreateWindowEx(flStyleEx, ClassName, UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffff0000, CW_USEDEFAULT, CW_USEDEFAULT,
1487
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
5055 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5056 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5057 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5058
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5059 if(hwndOwner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5060 SetParent(hwndframe, hwndOwner);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5061
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5062 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5063 /* Attempt to enable Aero glass background on the entire window */
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5064 if(_DwmExtendFrameIntoClientArea && _dw_composition && (flStyle & DW_FCF_COMPOSITED))
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5065 {
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5066 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY);
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5067 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5068 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5069 #endif
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5070
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5071 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
5077 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5080 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5082 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5083 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5084
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5085 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5086 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5087 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5088 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5089 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5090
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5091 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5092 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5093 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5094 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5095 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5096 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5097 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5098 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5099
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5100 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5101 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5102
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5103 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5104 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5108 * Create a new scroll Box to be packed.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5109 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5110 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5111 * pad: Number of pixels to pad around the box.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5112 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5113 HWND API dw_scrollbox_new(int type, int pad)
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5114 {
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5115 ColorInfo *cinfo = calloc(sizeof(ColorInfo), 1);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5116 HWND hwndframe, box = dw_box_new(type, pad);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5117 HWND tmpbox = dw_box_new(DW_VERT, 0);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5118 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5119
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5120 cinfo->fore = cinfo->back = -1;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5121
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5122 hwndframe = CreateWindow(ScrollClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5123 NULL,
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5124 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5125 0,0,0,0,
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5126 DW_HWND_OBJECT,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5127 NULL,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5128 DWInstance,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5129 NULL);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5130
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5131 cinfo->buddy = box;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5132 cinfo->combo = tmpbox;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5133 SetParent(tmpbox, hwndframe);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5134 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)cinfo);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5135 return hwndframe;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5136 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5137
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5138 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5139 * Returns the position of the scrollbar in the scrollbox
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5140 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5141 * handle: Handle to the scrollbox to be queried.
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5142 * orient: The vertical or horizontal scrollbar.
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5143 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5144 int API dw_scrollbox_get_pos( HWND handle, int orient )
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5145 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5146 SCROLLINFO si;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5147 int bar = SB_HORZ;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5148
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5149 if(orient == DW_VERT)
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5150 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5151 bar = SB_VERT;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5152 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5153
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5154 si.cbSize = sizeof(SCROLLINFO);
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5155 si.fMask = SIF_POS;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5156
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5157 /* Get the current scroll positions */
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5158 if(!GetScrollInfo(handle, bar, &si))
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5159 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5160 return -1;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5161 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5162 return si.nPos;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5163 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5164
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5165 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5166 * Gets the range for the scrollbar in the scrollbox.
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5167 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5168 * handle: Handle to the scrollbox to be queried.
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5169 * orient: The vertical or horizontal scrollbar.
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5170 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5171 int API dw_scrollbox_get_range( HWND handle, int orient )
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5172 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5173 SCROLLINFO si;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5174 int bar = SB_HORZ;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5175
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5176 if(orient == DW_VERT)
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5177 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5178 bar = SB_VERT;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5179 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5180
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5181 si.cbSize = sizeof(SCROLLINFO);
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5182 si.fMask = SIF_RANGE;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5183
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5184 /* Get the current scroll positions */
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5185 if(!GetScrollInfo(handle, bar, &si))
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5186 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5187 return -1;
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5188 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5189 return si.nMax;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5190 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5191 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
5194 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5198 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5200 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5201 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5202
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5203 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5204 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5205 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5206 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5207
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5208 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5209 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5210 WS_VISIBLE | WS_CHILD,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5211 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5212 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5213 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5214 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5215 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5216
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5217 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5218 UTF8toWide(title),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5219 WS_CHILD | BS_GROUPBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5220 WS_VISIBLE | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5221 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5222 hwndframe,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5223 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5224 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5225 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5226
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5227 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
1042
05ff61fd60d7 Initialize the groupbox title to the default font while creating it on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1039
diff changeset
5228 dw_window_set_font(hwndframe, DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5229 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5233 * Create a new MDI Frame to be packed.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5234 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5235 * id: An ID to be used with dw_window_from_id or 0L.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5236 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5237 HWND API dw_mdi_new(unsigned long id)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5238 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5239 CLIENTCREATESTRUCT ccs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5240 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5242 ccs.hWindowMenu = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5243 ccs.idFirstChild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5244
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5245 hwndframe = CreateWindow(TEXT("MDICLIENT"),
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5246 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5247 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5248 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5249 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5250 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5251 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5252 &ccs);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5253 return hwndframe;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5254 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5255
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5256 /*
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5257 * Create a new HTML browser frame to be packed.
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5258 * Parameters:
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5259 * id: An ID to be used with dw_window_from_id or 0L.
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5260 */
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5261 HWND API dw_html_new(unsigned long id)
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5262 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5263 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5264 return CreateWindow(BrowserClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5265 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5266 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5267 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5268 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5269 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5270 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5271 NULL);
913
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
5272 #else
1358
2f5e54b0c5c4 dw_debug() lines in dw_html_new() should end with a newline.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1354
diff changeset
5273 dw_debug("HTML widget not available; Support not enabled in this build.\n");
913
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
5274 return 0;
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
5275 #endif
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5276 }
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5277
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5278 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5279 void _dw_html_action(HWND hwnd, int action);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5280 int _dw_html_raw(HWND hwnd, char *string);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5281 int _dw_html_url(HWND hwnd, char *url);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5282 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5283
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5284 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5285 * Causes the embedded HTML widget to take action.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5286 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5287 * handle: Handle to the window.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5288 * action: One of the DW_HTML_* constants.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5289 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5290 void API dw_html_action(HWND handle, int action)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5291 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5292 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5293 _dw_html_action(handle, action);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5294 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5295 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5296
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5297 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5298 * Render raw HTML code in the embedded HTML widget..
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5299 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5300 * handle: Handle to the window.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5301 * string: String buffer containt HTML code to
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5302 * be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5303 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5304 * DW_ERROR_NONE (0) on success.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5305 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5306 int API dw_html_raw(HWND handle, char *string)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5307 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5308 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5309 return _dw_html_raw(handle, string);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5310 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5311 return DW_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5312 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5313 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5314
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5315 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5316 * Render file or web page in the embedded HTML widget..
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5317 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5318 * handle: Handle to the window.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5319 * url: Universal Resource Locator of the web or
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5320 * file object to be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5321 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5322 * DW_ERROR_NONE (0) on success.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5323 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5324 int API dw_html_url(HWND handle, char *url)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5325 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5326 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5327 return _dw_html_url(handle, url);
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5328 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5329 return DW_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5330 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5331 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5332
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5333 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 * Parameters:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5336 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5338 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5340 return CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5341 NULL,
1073
659b3c6a8959 Bitmap type widgets shouldn't rescale the image to fit on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1062
diff changeset
5342 SS_BITMAP | SS_CENTERIMAGE | WS_VISIBLE |
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5343 WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5344 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5345 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5346 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5347 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5348 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5357 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5359 ULONG flags = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5360 HWND tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5361 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5362 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5363
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5364 if(!top)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5365 flags = TCS_BOTTOM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5366
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5367 tmp = CreateWindow(WC_TABCONTROL,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5368 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5369 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | flags,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5370 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5371 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5372 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5373 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5374 NULL);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5375 cinfo->fore = cinfo->back = -1;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5376 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5377 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5378 dw_window_set_data(tmp, "_dw_array", (void *)array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5379 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5380 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5389 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5391 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5399 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5401 HMENUI tmp;
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5402 MENUINFO mi;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5403
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5404 tmp = (HMENUI)CreateMenu();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5405
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5406 mi.cbSize = sizeof(MENUINFO);
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5407 mi.fMask = MIM_MENUDATA;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5408 mi.dwMenuData = (ULONG_PTR)1;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5409
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5410 SetMenuInfo( (HMENU)tmp, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5411
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5412 dw_window_set_data(location, "_dw_menu", (void *)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5413
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5414 SetMenu(location, (HMENU)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5415 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5423 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5425 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5426 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5427 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5428
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5429 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5430 mymenu = (HMENU)dw_window_get_data((HWND)mymenu, "_dw_menu");
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
5431 if(IsMenu(mymenu))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5432 DestroyMenu(mymenu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5433 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5436 /* Internal function to make sure menu ID isn't in use */
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5437 int _menuid_allocated(int id)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5438 {
1310
47dbe605a03f Removed an unused variable in the new code on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1309
diff changeset
5439 SignalHandler *tmp = Root;
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5440
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5441 while(tmp)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5442 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5443 if(tmp->id == id)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5444 return TRUE;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5445 tmp = tmp->next;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5446 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5447 return FALSE;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5448 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5449
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5453 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * check: If TRUE menu is "check"able.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5458 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5461 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5463 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5464 HMENU mymenu = (HMENU)menux;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5465 char buffer[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5466 int is_checked, is_disabled;
1363
cdbe26a4b116 Mingw doesn't like writing to a compile time variable in dw_menu_append_item()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1362
diff changeset
5467 char *menutitle = title;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5468
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5469 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5470 * Check if this is a menubar; if so get the menu object
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5471 * for the menubar
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5472 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5473 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5474 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5475
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5476 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5477 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5478 mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5479
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5480 /* Convert from OS/2 style accellerators to Win32 style */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5481 if (title)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5482 {
1363
cdbe26a4b116 Mingw doesn't like writing to a compile time variable in dw_menu_append_item()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1362
diff changeset
5483 char *tmp = menutitle = _alloca(strlen(title)+1);
cdbe26a4b116 Mingw doesn't like writing to a compile time variable in dw_menu_append_item()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1362
diff changeset
5484
cdbe26a4b116 Mingw doesn't like writing to a compile time variable in dw_menu_append_item()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1362
diff changeset
5485 strcpy(tmp, title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5486
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5487 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5488 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5489 if(*tmp == '~')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5490 *tmp = '&';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5491 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5492 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5493 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5494
1363
cdbe26a4b116 Mingw doesn't like writing to a compile time variable in dw_menu_append_item()...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1362
diff changeset
5495 if (menutitle && *menutitle)
1305
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5496 {
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5497 /* Code to autogenerate a menu ID if not specified or invalid
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5498 * First pool is smaller for transient popup menus
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5499 */
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5500 if(id == (ULONG)-1)
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5501 {
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5502 static ULONG tempid = 61000;
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5503
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5504 tempid++;
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5505 id = tempid;
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5506
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5507 if(tempid > 65500)
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5508 tempid = 61000;
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5509 }
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5510 /* Second pool is larger for more static windows */
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5511 else if(!id || id >= 30000)
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5512 {
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5513 static ULONG menuid = 30000;
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5514
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5515 do
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5516 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5517 menuid++;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5518 if(menuid > 60000)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5519 menuid = 30000;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5520 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5521 while(_menuid_allocated(menuid));
1305
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5522 id = menuid;
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5523 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5524 mii.fType = MFT_STRING;
1305
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5525 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5526 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5527 mii.fType = MFT_SEPARATOR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5528
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5529 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5530 * Handle flags
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5531 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5532 is_checked = (flags & DW_MIS_CHECKED) ? 1 : 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5533 if ( is_checked )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5534 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5535 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5536 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5537 is_disabled = (flags & DW_MIS_DISABLED) ? 1 : 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5538 if ( is_disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5539 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5540 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5541 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5542
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5543 mii.wID = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5544 if (IsMenu((HMENU)submenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5545 mii.hSubMenu = (HMENU)submenu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5546 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5547 mii.hSubMenu = 0;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5548 mii.dwTypeData = UTF8toWide(menutitle);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5549 mii.cch = (UINT)_tcslen(mii.dwTypeData);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5550
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5551 InsertMenuItem(mymenu, 65535, TRUE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5552
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5553 _snprintf(buffer, 30, "_dw_id%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5554 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_POINTER(mymenu) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5555 _snprintf(buffer, 30, "_dw_checkable%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5556 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(check) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5557 _snprintf(buffer, 30, "_dw_ischecked%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5558 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(is_checked) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5559 _snprintf(buffer, 30, "_dw_isdisabled%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5560 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(is_disabled) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5561
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5562 if (submenu)
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5563 {
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5564 MENUINFO mi;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5565
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5566 mi.cbSize = sizeof(MENUINFO);
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5567 mi.fMask = MIM_MENUDATA;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5568 mi.dwMenuData = (ULONG_PTR)mymenu;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5569
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5570 SetMenuInfo( (HMENU)submenu, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5571 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5572
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5573 if (IsWindow(menux) && !IsMenu((HMENU)menux))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5574 DrawMenuBar(menux);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5575 return (HWND)(uintptr_t)id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 * Sets the state of a menu item check.
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5580 * Deprecated: use dw_menu_item_set_state()
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5582 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5586 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5588 MENUITEMINFO mii;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5589 HMENU mymenu = (HMENU)menux;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5590 char buffer[30];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5591
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5592 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5593 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5594
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5595 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5596 * Get the current state of the menu item in case it already has some other state set on it
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5597 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5598 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5599 GetMenuItemInfo( mymenu, id, FALSE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5600
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5601 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5602 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5603 if (check)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5604 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5605 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5606 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5607 SetMenuItemInfo( mymenu, id, FALSE, &mii );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5608 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5609 * Keep our internal state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5610 */
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5611 _snprintf( buffer, 30, "_dw_ischecked%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5612 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(check) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5613 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5614
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5615 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5616 * Sets the state of a menu item.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5617 * Parameters:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5618 * menu: The handle to the existing menu.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5619 * id: Menuitem id.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5620 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5621 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5622 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5623 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5624 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5625 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5626 HMENU mymenu = (HMENU)menux;
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5627 char buffer1[31] = {0},buffer2[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5628 int check;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5629 int disabled;
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5630
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5631 if (IsWindow(menux) && !IsMenu(mymenu))
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5632 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5633
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5634 _snprintf( buffer1, 30, "_dw_ischecked%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5635 check = DW_POINTER_TO_INT(dw_window_get_data( DW_HWND_OBJECT, buffer1 ));
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5636 _snprintf( buffer2, 30, "_dw_isdisabled%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5637 disabled = DW_POINTER_TO_INT(dw_window_get_data( DW_HWND_OBJECT, buffer2 ));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5638
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5639 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5640
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5641 mii.cbSize = sizeof(MENUITEMINFO);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5642 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5643 if ( (state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5644 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5645 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5646 * If we are changing state of "checked" base our setting on the passed flag...
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5647 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5648 if ( state & DW_MIS_CHECKED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5649 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5650 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5651 check = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5652 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5653 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5654 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5655 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5656 check = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5657 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5658 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5659 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5660 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5661 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5662 * ...otherwise base our setting on the current "checked" state.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5663 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5664 if ( check )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5665 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5666 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5667 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5668 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5669 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5670 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5671 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5672 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5673 if ( (state & DW_MIS_ENABLED) || (state & DW_MIS_DISABLED) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5674 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5675 if ( state & DW_MIS_DISABLED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5676 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5677 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5678 disabled = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5679 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5680 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5681 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5682 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5683 disabled = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5684 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5685 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5686 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5687 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5688 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5689 * ...otherwise base our setting on the current "checked" state.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5690 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5691 if ( disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5692 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5693 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5694 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5695 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5696 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5697 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5698 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5699 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5700 SetMenuItemInfo( mymenu, id, FALSE, &mii );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5701 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5702 * Keep our internal checked state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5703 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5704 dw_window_set_data( DW_HWND_OBJECT, buffer1, DW_INT_TO_POINTER(check) );
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5705 dw_window_set_data( DW_HWND_OBJECT, buffer2, DW_INT_TO_POINTER(disabled) );
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5708 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5709 * Deletes the menu item specified
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5710 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5711 * menu: The handle to the menu in which the item was appended.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5712 * id: Menuitem id.
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5713 * Returns:
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5714 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5715 */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5716 int API dw_menu_delete_item(HMENUI menux, unsigned long id)
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5717 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5718 HMENU mymenu = (HMENU)menux;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5719
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5720 if ( IsWindow(menux) && !IsMenu(mymenu) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5721 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5722
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5723 if ( mymenu == 0 || DeleteMenu(mymenu, id, MF_BYCOMMAND) == 0 )
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5724 return DW_ERROR_UNKNOWN;
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5725
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5726 /* If the ID was autogenerated it is safe to remove it */
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5727 if(id >= 30000)
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5728 dw_signal_disconnect_by_window((HWND)(uintptr_t)id);
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5729
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5730 /* Make sure the menu is redrawn if needed */
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5731 if( (HMENU)menux != mymenu )
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5732 DrawMenuBar(menux);
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5733 return DW_ERROR_NONE;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5734 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5735
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5744 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5746 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5747 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5748 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5749
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5750 if(IsWindow(*menu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5751 mymenu = (HMENU)dw_window_get_data(*menu, "_dw_menu");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5752
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5753 popup = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5754 TrackPopupMenu(mymenu, 0, x, y, 0, parent, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5755 PostMessage(DW_HWND_OBJECT, WM_USER+5, (LPARAM)mymenu, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5756 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5766 HWND API dw_container_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5768 HWND tmp = CreateWindow(WC_LISTVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5769 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5770 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5771 (multi ? 0 : LVS_SINGLESEL) |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5772 LVS_REPORT | LVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5773 LVS_SHAREIMAGELISTS | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5774 WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5775 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5776 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5777 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5778 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5779 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5780 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5781
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5782 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5783 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5784 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5785 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5786 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5787
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5788 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5789 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
5790 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5791
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5792 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5793 dw_window_set_font(tmp, DefaultFont);
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5794 /* If we are running XP or higher... */
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5795 if(IS_XPPLUS)
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5796 {
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5797 /* Enable double buffering to prevent flicker */
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5798 ListView_SetExtendedListViewStyleEx(tmp, LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER);
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5799 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5800 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5804 * Create a tree object to be packed.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5805 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5806 * id: An ID to be used for getting the resource from the
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5807 * resource file.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5808 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5809 HWND API dw_tree_new(ULONG id)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5810 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5811 HWND tmp = CreateWindow(WC_TREEVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5812 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5813 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5814 TVS_HASLINES | TVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5815 TVS_HASBUTTONS | TVS_LINESATROOT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5816 WS_BORDER | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5817 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5818 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5819 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5820 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5821 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5822 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5823 TreeView_SetItemHeight(tmp, 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5824
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5825 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5826 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5827 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5828 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5829 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5830
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5831 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5832 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
5833 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5835 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5836 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5837 return tmp;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5838 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5839
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5840 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5841 * Returns the current X and Y coordinates of the mouse pointer.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5842 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5843 * x: Pointer to variable to store X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5844 * y: Pointer to variable to store Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5845 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5846 void API dw_pointer_query_pos(long *x, long *y)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5847 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5848 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5849
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5850 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5851 if(x && y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5852 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5853 *x = ptl.x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5854 *y = ptl.y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5855 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5856 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5857
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5858 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5859 * Sets the X and Y coordinates of the mouse pointer.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5860 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5861 * x: X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5862 * y: Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5863 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5864 void API dw_pointer_set_pos(long x, long y)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5865 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5866 SetCursorPos(x, y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5867 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5868
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5869 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
5873 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5875 HWND API dw_text_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5877 HWND tmp = CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5878 UTF8toWide(text),
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
5879 SS_NOPREFIX | SS_NOTIFY | SS_LEFTNOWORDWRAP |
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
5880 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5881 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5882 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5883 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5884 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5885 NULL);
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5886 #ifdef AEROGLASS
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5887 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5888
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5889 cinfo->back = cinfo->fore = -1;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5890
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5891 cinfo->pOldProc = SubclassWindow(tmp, _staticwndproc);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5892 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5893 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5894 dw_window_set_font(tmp, DefaultFont);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
5895 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5896 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5900 * Create a new status text window (widget) to be packed.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5901 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5902 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
5903 * id: An ID to be used with dw_window_from_id() or 0L.
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5904 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5905 HWND API dw_status_text_new(char *text, ULONG id)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5906 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5907 HWND tmp = CreateWindow(StatusbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5908 UTF8toWide(text),
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5909 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5910 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5911 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5912 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5913 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5914 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5915 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5916 return tmp;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5917 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5918
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5919 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
5922 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5924 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 {
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
5926
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5927 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
5928 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5929 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5930 WS_VISIBLE | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5931 WS_VSCROLL | ES_MULTILINE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5932 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5933 WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5934 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5935 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5936 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5937 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5938 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5939 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5940
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5941 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5942 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5943 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5944 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5945 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5946
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5947 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5948 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
5949 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5951 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5952 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5953 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
5960 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5962 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5964 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5965 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5966 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5967 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5968 WS_BORDER | ES_AUTOHSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5969 WS_VISIBLE | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5970 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5971 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5972 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5973 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5974 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5975 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5976
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5977 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5978
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5979 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5980 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5981 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5982 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5986 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
5989 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5991 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5993 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5994 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5995 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5996 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5997 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5998 ES_AUTOHSCROLL | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
5999 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6000 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6001 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6002 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6003 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6004 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6005
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6006 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6007
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6008 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6009 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6010 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6011 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6014 BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6015 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6016 ColorInfo *cinfo = (ColorInfo *)lp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6017
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6018 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6019 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6020 cinfo->buddy = handle;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6021 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6022 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6023 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6024 return FALSE;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6025 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6026
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 * text: The default text to be in the combpbox widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6031 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6033 HWND API dw_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6035 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6036 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6037 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6038 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6039 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6040 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6041 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6042 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6043 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6044 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6045 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6046
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6047 if(!cinfo || !cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6048 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6049 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6050 free(cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6051 if(cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6052 free(cinfo2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6053 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6054 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6055 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6056
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6057 cinfo2->fore = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6058 cinfo2->back = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6059 cinfo2->combo = cinfo->combo = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6060 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2);
1399
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6061 cinfo->buddy = cinfo2->buddy;
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6062
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6063 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6064 dw_window_set_font(tmp, DefaultFont);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6065 SetWindowText(tmp, UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6066 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6073 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6075 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6077 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6078
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6079 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6080 UTF8toWide(text),
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6081 WS_CHILD | BS_PUSHBUTTON |
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6082 WS_VISIBLE | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6083 0,0,0,0,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6084 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6085 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6086 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6087 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6088 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6089 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6090
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6091 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6092 dw_window_set_font(tmp, DefaultFont);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6093 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6096 #ifdef TOOLBAR
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6097 /* Internal function to create a grayscale bitmap from a color one */
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6098 void _to_grayscale(HBITMAP hbm, int width, int height)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6099 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6100 HDC hdc = CreateCompatibleDC(NULL);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6101 if (hdc)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6102 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6103 HBITMAP hbmPrev = SelectBitmap(hdc, hbm);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6104 int x, y;
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6105
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6106 for(y=0;y<height;y++)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6107 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6108 for(x=0;x<width;x++)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6109 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6110 COLORREF c = GetPixel(hdc, x, y);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6111 /* Use half-values then add 127 to make it look washed out */
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6112 int luma = (int)(GetRValue(c)*0.15 + GetGValue(c)*0.3+ GetBValue(c)*0.06) + 127;
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6113
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6114 SetPixel(hdc, x, y, RGB(luma,luma,luma));
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6115 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6116 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6117 SelectBitmap(hdc, hbmPrev);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6118 DeleteDC(hdc);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6119 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6120 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6121
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6122 /* Internal function to create a toolbar based button */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6123 HWND _create_toolbar(char *text, ULONG id, HICON icon, HBITMAP hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6124 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6125 HWND tmp;
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6126 HIMAGELIST imlist, dimlist;
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6127 BITMAP bmi = { 0 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6128 TBBUTTON tbButtons[] = {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6129 { MAKELONG(0, 0), id, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, 0}
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6130 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6131
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6132 /* Get the bitmap from either the icon or bitmap itself */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6133 if(hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6134 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6135 GetObject(hbitmap, sizeof(BITMAP), &bmi);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6136 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32, 1, 0);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6137 ImageList_Add(imlist, hbitmap, NULL);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6138 dimlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32, 1, 0);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6139 _to_grayscale(hbitmap, bmi.bmWidth, bmi.bmHeight);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6140 ImageList_Add(dimlist, hbitmap, NULL);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6141 DeleteObject(hbitmap);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6142 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6143 else if(icon)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6144 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6145 ICONINFO iconinfo;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6146
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6147 GetIconInfo(icon, &iconinfo);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6148 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6149 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6150 ImageList_AddIcon(imlist, icon);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6151 dimlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6152 _to_grayscale(iconinfo.hbmColor, bmi.bmWidth, bmi.bmHeight);
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6153 ImageList_Add(dimlist, iconinfo.hbmColor, iconinfo.hbmMask);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6154 DeleteObject(iconinfo.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6155 DeleteObject(iconinfo.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6156 DestroyIcon(icon);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6157 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6158 else
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6159 return 0;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6160
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6161 /* Create the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6162 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE |
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6163 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6164
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6165 /* Disable visual styles by default */
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6166 if(_SetWindowTheme)
1750
1de7daad85a3 Updated readme, removed debug message and committed fixes for ANSI builds on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1749
diff changeset
6167 _SetWindowTheme(tmp, L"", L"");
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6168
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6169 /* Insert the single bitmap and button into the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6170 SendMessage(tmp, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
1724
48983a2f839f Toolbar bitmap buttons don't seem to draw properly smaller than 20x20 on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1723
diff changeset
6171 SendMessage(tmp, TB_SETBUTTONSIZE, 0, MAKELPARAM(bmi.bmWidth, bmi.bmHeight));
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6172 SendMessage(tmp, TB_SETPADDING, 0, 0);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6173 SendMessage(tmp, TB_SETIMAGELIST, 0, (LPARAM)imlist);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6174 SendMessage(tmp, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)dimlist);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
6175 SendMessage(tmp, TB_ADDBUTTONS, 1, (LPARAM) &tbButtons);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6176
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6177 _create_tooltip(tmp, text);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6178 return tmp;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6179 }
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6180 #endif
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6181
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6188 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6190 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6191 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
6192 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6193 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
6194 #ifdef TOOLBAR
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6195 if(tmp = _create_toolbar(text, id, icon, hbitmap))
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6196 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6197 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6198 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6199 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6200 return tmp;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6201 }
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6202 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6203
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6204 tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6205 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6206 WS_CHILD | BS_PUSHBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6207 WS_VISIBLE | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6208 (icon ? BS_ICON : BS_BITMAP),
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6209 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6210 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6211 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6212 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6213 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6214
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6215 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6216 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6217
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6218 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6219
759
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6220 _create_tooltip(tmp, text);
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6221
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6222 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6223 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6224 SendMessage(tmp, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) icon);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6225 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6226 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6227 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6228 SendMessage(tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6229 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6230 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6234 * Create a new bitmap button window (widget) to be packed from a file.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6235 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6236 * text: Bubble help text to be displayed.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6237 * id: An ID to be used with dw_window_from_id() or 0L.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6238 * filename: Name of the file, omit extention to have
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6239 * DW pick the appropriate file extension.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6240 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6241 */
507
c607eb385e58 Added missing calling conventions. Thanks Bastian for pointing this out.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 506
diff changeset
6242 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6243 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6244 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6245 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6246 HBITMAP hbitmap = 0;
1256
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6247 HANDLE hicon = 0;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6248 int windowtype = 0;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6249
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6250 if (!cinfo)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6251 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6252
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6253 #ifdef GDIPLUS
1256
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6254 if((hicon = _dw_load_icon(filename)))
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6255 windowtype = BS_ICON;
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6256 else
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6257 {
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6258 hbitmap = _dw_load_bitmap(filename, NULL);
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6259 windowtype = BS_BITMAP;
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6260 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6261 #else
1256
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6262 windowtype = _dw_get_image_handle(filename, &hicon, &hbitmap);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6263 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6264
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6265 #ifdef TOOLBAR
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6266 if(tmp = _create_toolbar(text, id, hicon, hbitmap))
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6267 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6268 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6269 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6270 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6271 return tmp;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6272 }
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6273 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6274 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6275 NULL,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6276 windowtype | WS_CHILD | BS_PUSHBUTTON | WS_CLIPCHILDREN | WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6277 0,0,0,0,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6278 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6279 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6280 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6281 NULL);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6282
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6283 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6284 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6285
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6286 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6287
759
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6288 _create_tooltip(tmp, text);
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6289
1256
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6290 if (hicon)
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6291 {
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6292 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hicon);
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6293 }
51892bf7fe01 Attempt on Windows to use an icon handle for bitmap buttons before a bitmap...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1255
diff changeset
6294 else if (hbitmap)
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6295 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6296 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6297 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6298 return tmp;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6299 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6300
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6301 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6302 * Create a new bitmap button window (widget) to be packed from data.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6303 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6304 * text: Bubble help text to be displayed.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6305 * id: An ID to be used with dw_window_from_id() or 0L.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6306 * data: The contents of the image
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6307 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6308 * len: length of str
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6309 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6310 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6311 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6312 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6313 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6314 HBITMAP hbitmap = 0;
1257
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6315 HANDLE hicon = 0;
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6316 char *file;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6317 FILE *fp;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6318 int windowtype = BS_BITMAP;
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6319
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6320 if (!cinfo)
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6321 return 0;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6322
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6323 file = _tempnam( _dw_alternate_temp_dir, "dw" );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6324 if ( file != NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6325 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6326 fp = fopen( file, "wb" );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6327 if ( fp != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6328 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6329 fwrite( data, 1, len, fp );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6330 fclose( fp );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6331 #ifdef GDIPLUS
1257
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6332 if((hicon = _dw_load_icon(file)))
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6333 windowtype = BS_ICON;
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6334 else
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6335 hbitmap = _dw_load_bitmap(file, NULL);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6336 #else
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6337 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6338 hbitmap = (HBITMAP)LoadImage( NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6339 else /* otherwise its assumed to be an ico */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6340 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6341 hicon = LoadImage( NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6342 windowtype = BS_ICON;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6343 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6344 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6345 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6346 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6347 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6348 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6349 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6350 return 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6351 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6352 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6353 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6354 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6355
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6356 #ifdef TOOLBAR
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6357 if(tmp = _create_toolbar(text, id, hicon, hbitmap))
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6358 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6359 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6360 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6361 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6362 return tmp;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6363 }
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6364 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6365 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6366 NULL,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6367 WS_CHILD | BS_PUSHBUTTON |
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6368 windowtype | WS_CLIPCHILDREN |
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6369 WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6370 0,0,0,0,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6371 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6372 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6373 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6374 NULL );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6375
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6376 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6377 cinfo->pOldProc = SubclassWindow( tmp, _BtProc );
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6378
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6379 SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)cinfo );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6380
759
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6381 _create_tooltip(tmp, text);
6d880e68e8d4 Removed the custom tooltip creator I ported from OS/2 and switched to using native Win32 tooltips.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 757
diff changeset
6382
1257
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6383 if ( hicon )
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6384 {
35b177e8a0a2 Basically a repeat of that last fix except for the data version of the function.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1256
diff changeset
6385 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) hicon);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6386 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6387 else if( hbitmap )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6388 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6389 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6390 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6391 return tmp;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6392 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6393
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6394 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6398 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6400 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6402 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE,
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6403 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6404 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6405 WS_CHILD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6406 ES_NUMBER | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6407 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6408 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6409 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6410 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6411 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6412 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6413 UPDOWN_CLASS,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6414 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6415 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6416 UDS_ARROWKEYS | UDS_SETBUDDYINT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6417 UDS_WRAP | UDS_NOTHOUSANDS | WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6418 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6419 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6420 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6421 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6422 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6423 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6424
1025
3573878d1239 Make sure the initial spinbutton limits on Windows match the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1006
diff changeset
6425 SendMessage(tmp, UDM_SETRANGE32, (WPARAM)-65536,(LPARAM)65536);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6426 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6427 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6428 cinfo->buddy = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6429
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6430 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6431 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6432
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6433 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6434 cinfo->buddy = buddy;
1119
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6435 /* The horrible spinbutton workaround isn't necessary
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6436 * any more on Vista or 7... but still seems necessary
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6437 * for XP, so only enable it if on XP or lower.
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6438 */
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6439 if(!IS_VISTAPLUS)
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6440 {
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6441 cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc);
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6442 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6443
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6444 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6445 dw_window_set_font(buddy, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6446 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6453 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6455 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6457 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6458 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6459 WS_CHILD | BS_AUTORADIOBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6460 WS_CLIPCHILDREN | WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6461 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6462 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6463 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6464 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6465 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6466 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6467 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6468 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6469 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6470 dw_window_set_font(tmp, DefaultFont);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
6471 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6472 return tmp;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6473 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6474
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6475
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6476 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6477 * Create a new slider window (widget) to be packed.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6478 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6479 * vertical: TRUE or FALSE if slider is vertical.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6480 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6481 * id: An ID to be used with dw_window_from_id() or 0L.
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6482 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6483 HWND API dw_slider_new(int vertical, int increments, ULONG id)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6484 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6485 HWND tmp = CreateWindow(TRACKBAR_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6486 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6487 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6488 (vertical ? TBS_VERT : TBS_HORZ),
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6489 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6490 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6491 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6492 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6493 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6494 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6495
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6496 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6497
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6498 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6499 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
6500 SendMessage(tmp, TBM_SETRANGE, (WPARAM)FALSE, MAKELPARAM(0, increments-1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6501 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6505 * Create a new scrollbar window (widget) to be packed.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6506 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6507 * vertical: TRUE or FALSE if scrollbar is vertical.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6508 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6509 * id: An ID to be used with dw_window_from_id() or 0L.
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6510 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
6511 HWND API dw_scrollbar_new(int vertical, ULONG id)
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6512 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6513 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6514 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6515 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6516 (vertical ? SBS_VERT : SBS_HORZ),
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6517 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6518 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6519 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6520 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6521 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6522 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6523
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6524 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6525
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6526 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6527 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6528 dw_window_set_data(tmp, "_dw_scrollbar", (void *)1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6529 return tmp;
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6530 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6531
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6532 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
6533 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6535 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6537 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6539 return CreateWindow(PROGRESS_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6540 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6541 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6542 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6543 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6544 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6545 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6546 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6553 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6555 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6557 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6558 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6559 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6560 WS_CHILD | BS_AUTOCHECKBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6561 BS_TEXT | WS_CLIPCHILDREN | WS_VISIBLE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6562 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6563 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6564 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6565 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6566 NULL);
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6567 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6568 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6569 dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6570 dw_window_set_font(tmp, DefaultFont);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
6571 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6572 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6578 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6581 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6583 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6584 LISTBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6585 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6586 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6587 WS_CHILD | LBS_HASSTRINGS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6588 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6589 WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) ,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
6590 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6591 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6592 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6593 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6594 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6595 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6596
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6597 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6598 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6599 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6600 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6601 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6602
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6603 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6604 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6605 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6606
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6607 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6608 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6609 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 */
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
6618 void API dw_window_set_icon(HWND handle, HICN icon)
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
6619 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6620 int iicon = DW_POINTER_TO_INT(icon);
975
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
6621 HICON hicon = iicon < 65536 ? LoadIcon(DWInstance, MAKEINTRESOURCE(iicon)) : (HICON)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6622
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6623 SendMessage(handle, WM_SETICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6624 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6625 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6626 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6627
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6628 /* Internal function to set bitmap for the next two functions */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6629 void _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6630 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6631 HBITMAP oldbitmap = 0;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6632 HANDLE oldicon = 0;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6633 TCHAR tmpbuf[100] = {0};
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6634
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6635 if (!icon && !hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6636 return;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6637
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6638 GetClassName(handle, tmpbuf, 99);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6639
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6640 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6641 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6642 oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6643 oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6644 SendMessage(handle, BM_SETIMAGE,
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6645 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP),
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6646 (icon ? (LPARAM)icon : (LPARAM)hbitmap));
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6647 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6648 #ifdef TOOLBAR
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6649 /* Bitmap Buttons */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6650 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6651 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6652 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6653 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6654 BITMAP bmi = { 0 };
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6655
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6656 if(hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6657 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6658 GetObject(hbitmap, sizeof(BITMAP), &bmi);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6659 ImageList_Replace(imlist, 0, hbitmap, NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6660 _to_grayscale(hbitmap, bmi.bmWidth, bmi.bmHeight);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6661 ImageList_Replace(dimlist, 0, hbitmap, NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6662 DeleteObject(hbitmap);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6663 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6664 else if(icon)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6665 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6666 ICONINFO iconinfo;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6667
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6668 GetIconInfo(icon, &iconinfo);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6669 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6670 ImageList_ReplaceIcon(imlist, 0, icon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6671 _to_grayscale(iconinfo.hbmColor, bmi.bmWidth, bmi.bmHeight);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6672 ImageList_Replace(dimlist, 0, iconinfo.hbmColor, iconinfo.hbmMask);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6673 DeleteObject(iconinfo.hbmColor);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6674 DeleteObject(iconinfo.hbmMask);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6675 DestroyIcon(icon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6676 }
1826
10c59bb2c47f On Windows invalidate the bitmap button after changing the bitmap to force a redraw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1822
diff changeset
6677 InvalidateRect(handle, NULL, FALSE);
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6678 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6679 #endif
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6680 else
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6681 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6682 oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6683 oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6684 SendMessage(handle, STM_SETIMAGE,
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6685 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP),
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6686 (icon ? (LPARAM)icon : (LPARAM)hbitmap));
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6687 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6688
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6689 if(oldbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6690 DeleteObject(oldbitmap);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6691 if(oldicon)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6692 DeleteObject(oldicon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6693
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6694 /* If we changed the bitmap... */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6695 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6696 Item *item = _box_item(handle);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6697
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6698 /* Check to see if any of the sizes need to be recalculated */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6699 if(item && (item->origwidth == -1 || item->origheight == -1))
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6700 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6701 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6702 /* Queue a redraw on the top-level window */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6703 _dw_redraw(_toplevel_window(handle), TRUE);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6704 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6705 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6706 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6707
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 * handle: Handle to the window.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6712 * id: An ID to be used to specify the icon,
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6713 * (pass 0 if you use the filename param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6714 * filename: a path to a file (Bitmap on OS/2 or
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6715 * Windows and a pixmap on Unix, pass
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6716 * NULL if you use the id param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6717 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6718 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6719 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6720 HBITMAP hbitmap = 0;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6721 HANDLE icon = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6722
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6723 if(id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6724 {
862
9750236bcdd5 Experimental change to bitmap loading to allow virtual transparent backgrounds using resources on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 843
diff changeset
6725 hbitmap = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_SHARED);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6726 icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6727 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6728 else if(filename)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6729 {
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6730 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6731 hbitmap = _dw_load_bitmap(filename, NULL);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6732 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6733 _dw_get_image_handle(filename, &icon, &hbitmap);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6734 #endif
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6735 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6736
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6737 _dw_window_set_bitmap(handle, icon, hbitmap);
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6738 }
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6739
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6740 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6741 * Sets the bitmap used for a given static window from data.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6742 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6743 * handle: Handle to the window.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6744 * id: An ID to be used to specify the icon,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6745 * (pass 0 if you use the data param)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6746 * data: the image from meory
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6747 * Bitmap on Windows and a pixmap on Unix, pass
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6748 * NULL if you use the id param)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6749 * len: length of data
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6750 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6751 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6752 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6753 HBITMAP hbitmap=0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6754 HICON icon=0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6755 char *file;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6756 FILE *fp;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6757
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6758 if (data)
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6759 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6760 file = _tempnam( _dw_alternate_temp_dir, "dw" );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6761 if ( file != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6762 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6763 fp = fopen( file, "wb" );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6764 if ( fp != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6765 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6766 fwrite( data, 1, len, fp );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6767 fclose( fp );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6768 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6769 hbitmap = _dw_load_bitmap(file, NULL);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6770 #else
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6771 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6772 hbitmap = (HBITMAP)LoadImage( NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6773 else /* otherwise its assumed to be an ico */
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6774 icon = LoadImage( NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
6775 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6776 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6777 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6778 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6779 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6780 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6781 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6782 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6783 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6784 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6785 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6786 if (icon == 0 && hbitmap == 0)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6787 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6788 }
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6789 else if ( id )
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6790 {
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6791 hbitmap = LoadBitmap( DWInstance, MAKEINTRESOURCE(id) );
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6792 icon = LoadImage( DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED );
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6793 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6794
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6795 _dw_window_set_bitmap(handle, icon, hbitmap);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6796 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6797
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6805 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6807 Box *thisbox;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6808 TCHAR tmpbuf[100] = {0}, *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6810 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6811
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6812 SetWindowText(handle, wtext);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6813
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6814 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6815 if ( _tcsnicmp( tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6816 SendMessage(handle, CB_SETEDITSEL, 0, MAKELPARAM(-1, 0));
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6817 else if ( _tcsnicmp( tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0 )
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6818 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6819 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6820 if( cinfo && cinfo->buddy )
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6821 SetWindowText( cinfo->buddy, wtext );
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6822 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6823 else if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 )
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6824 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6825 /* groupbox */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6826 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6827 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6828 SetWindowText( thisbox->grouphwnd, wtext );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6829 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6830 /* If we changed the text... */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6831 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6832 Item *item = _box_item(handle);
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6833
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6834 /* Check to see if any of the sizes need to be recalculated */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6835 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: 1415
diff changeset
6836 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6837 int newwidth, newheight;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6838
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6839 _control_size(handle, &newwidth, &newheight);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6840
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6841 /* 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: 1790
diff changeset
6842 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: 1790
diff changeset
6843 (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: 1790
diff changeset
6844 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6845 if(item->origwidth == -1)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6846 item->width = newwidth;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6847 if(item->origheight == -1)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6848 item->height = newheight;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6849 /* 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: 1790
diff changeset
6850 _dw_redraw(_toplevel_window(handle), TRUE);
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6851 }
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6852 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6853 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6854 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6856 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6857 * 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: 1387
diff changeset
6858 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6859 * 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: 1387
diff changeset
6860 * 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: 1387
diff changeset
6861 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6862 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: 1387
diff changeset
6863 {
1399
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6864 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6865
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6866 if(cinfo && cinfo->buddy)
8e569dd09d94 On Windows get the buddy from the child window data when creating a combobox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1397
diff changeset
6867 _create_tooltip(cinfo->buddy, bubbletext);
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6868 _create_tooltip(handle, bubbletext);
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6869 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6870
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6871 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6878 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6880 char *retbuf = NULL;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6881 TCHAR *tempbuf, tmpbuf[100] = { 0 };
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6882 int len;
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6883
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6884 GetClassName(handle, tmpbuf, 99);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6885
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6886 if ( _tcsnicmp( tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0 )
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6887 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6888 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6889
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6890 if( cinfo && cinfo->buddy )
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6891 handle = cinfo->buddy;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6892 else
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6893 return NULL;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6894 }
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6895
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6896 /* Figure out the wide length, allocate a temp buffer
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6897 * and fill it with the current text.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6898 */
1627
b41ecd439b47 dw_window_get_text() was truncating the text by 1 byte in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1624
diff changeset
6899 len = GetWindowTextLength(handle) + 1;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6900 if((tempbuf = _alloca(len * sizeof(TCHAR))))
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6901 GetWindowText(handle, tempbuf, len);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6902
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6903 /* Figure out the UTF8 length, allocate a return buffer
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6904 * and fill it with the UTF8 text and return it.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6905 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6906 if(tempbuf && (retbuf = WideToUTF8(tempbuf)))
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
6907 retbuf = _strdup(retbuf);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6908 return retbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6916 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 {
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: 1297
diff changeset
6918 if(handle < (HWND)65536)
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: 1297
diff changeset
6919 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6920 char buffer[31] = {0};
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: 1297
diff changeset
6921 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6922 ULONG id = (ULONG)(uintptr_t)handle;
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: 1297
diff changeset
6923
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6924 _snprintf(buffer, 30, "_dw_id%ld", id);
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: 1297
diff changeset
6925 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
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: 1297
diff changeset
6926
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: 1297
diff changeset
6927 if(mymenu && IsMenu(mymenu))
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: 1297
diff changeset
6928 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_DISABLED);
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: 1297
diff changeset
6929 }
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: 1297
diff changeset
6930 else
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: 1297
diff changeset
6931 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6939 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 {
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: 1297
diff changeset
6941 if(handle < (HWND)65536)
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: 1297
diff changeset
6942 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6943 char buffer[31] = {0};
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: 1297
diff changeset
6944 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6945 ULONG id = (ULONG)(uintptr_t)handle;
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: 1297
diff changeset
6946
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6947 _snprintf(buffer, 30, "_dw_id%ld", id);
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: 1297
diff changeset
6948 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
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: 1297
diff changeset
6949
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: 1297
diff changeset
6950 if(mymenu && IsMenu(mymenu))
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: 1297
diff changeset
6951 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_ENABLED);
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: 1297
diff changeset
6952 }
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: 1297
diff changeset
6953 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6954 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6955 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6957 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6958
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6959 BOOL CALLBACK _wfid(HWND handle, LPARAM lParam)
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6960 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6961 if(GetWindowLong(handle, GWL_ID) == lParam)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6962 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6963 _dw_wfid_hwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6964 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6965 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6966 return TRUE;
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6967 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6968
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6975 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6977 _dw_wfid_hwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6978 EnumChildWindows(handle, _wfid, (LPARAM)id);
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6979 return _dw_wfid_hwnd;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6980 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
6981
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6982 /* Internal box packing function called by the other 3 functions */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6983 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
6984 {
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
6985 Box *thisbox = NULL;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6986 TCHAR tmpbuf[100] = {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
6987
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
6988 /*
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
6989 * If you try and pack an item into itself VERY bad things can happen; like at least an
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
6990 * infinite loop on GTK! Lets be safe!
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
6991 */
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
6992 if(box == 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
6993 {
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6994 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
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
6995 return;
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
6996 }
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
6997
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
6998 GetClassName(box, tmpbuf, 99);
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: 1448
diff changeset
6999
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
7000 /* If we are in a scrolled box... extract the interal box */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7001 if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==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
7002 {
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
7003 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA);
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
7004 if(cinfo)
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
7005 {
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
7006 box = cinfo->buddy;
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
7007 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA);
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
7008 }
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
7009 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7010 else //if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==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
7011 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA);
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
7012 if(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
7013 {
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
7014 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
7015 Item *tmpitem, *thisitem = thisbox->items;
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7016
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
7017 /* Do some sanity bounds checking */
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7018 if(!thisitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7019 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
7020 if(index < 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
7021 index = 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
7022 if(index > 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
7023 index = 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
7024
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7025 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
7026
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
7027 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
7028 {
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
7029 if(z == index)
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
7030 x++;
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
7031 tmpitem[x] = thisitem[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
7032 x++;
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
7033 }
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
7034
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
7035 GetClassName(item, tmpbuf, 99);
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
7036
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
7037 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
7038 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
7039 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
7040 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
7041
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7042 if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==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
7043 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
7044 else
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7045 {
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
7046 if(_tcsnicmp(tmpbuf, TEXT("SysMonthCal32"), 13)==0)
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7047 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7048 RECT rc;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7049 MonthCal_GetMinReqRect(item, &rc);
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7050 width = 1 + rc.right - rc.left;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7051 height = 1 + rc.bottom - rc.top;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7052 tmpitem[index].type = TYPEITEM;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7053 }
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7054 else
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7055 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7056 if ( width == 0 && hsize == FALSE )
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7057 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7058 if ( height == 0 && vsize == FALSE )
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7059 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7060
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7061 tmpitem[index].type = TYPEITEM;
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7062 }
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
7063 }
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
7064
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
7065 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
7066 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
7067 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
7068 tmpitem[index].pad = pad;
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7069 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7070 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC;
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7071
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7072 /* If either of the parameters are -1 ... calculate the size */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7073 if(width == -1 || height == -1)
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7074 _control_size(item, 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
7075
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
7076 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
7077
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7078 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
7079 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
7080
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
7081 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
7082
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
7083 SetParent(item, box);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7084 if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==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
7085 {
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
7086 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(item, GWLP_USERDATA);
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
7087
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
7088 if(cinfo)
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
7089 {
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
7090 SetParent(cinfo->buddy, 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
7091 ShowWindow(cinfo->buddy, SW_SHOW);
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
7092 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 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
7093 }
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
7094 }
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7095 #ifdef TOOLBAR
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7096 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7097 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7098 #ifdef AEROGLASS
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7099 if(!(_dw_composition && (GetWindowLongPtr(_toplevel_window(box), GWL_EXSTYLE) & WS_EX_LAYERED)))
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7100 #endif
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7101 {
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7102 /* Enable double buffering if our window isn't composited */
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7103 SendMessage(item, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DOUBLEBUFFER);
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7104 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7105 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7106 #endif
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
7107 /* 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: 1669
diff changeset
7108 _dw_redraw(_toplevel_window(box), 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
7109 }
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
7110 }
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
7111
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
7112 /*
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7113 * Remove windows (widgets) from the box they are packed into.
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7114 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7115 * handle: Window handle of the packed item to be removed.
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7116 * Returns:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7117 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7118 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1766
diff changeset
7119 int API dw_box_unpack(HWND handle)
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7120 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7121 HWND parent = GetParent(handle);
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7122
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7123 if(handle && parent != HWND_DESKTOP)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7124 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7125 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA);
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7126
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7127 /* If the parent box has items...
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7128 * try to remove it from the layout
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7129 */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7130 if(thisbox && thisbox->count)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7131 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7132 int z, index = -1;
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7133 Item *tmpitem = NULL, *thisitem = thisbox->items;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7134
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7135 if(!thisitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7136 thisbox->count = 0;
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7137
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7138 for(z=0;z<thisbox->count;z++)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7139 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7140 if(thisitem[z].hwnd == handle)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7141 index = z;
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7142 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7143
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7144 if(index == -1)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7145 return DW_ERROR_GENERAL;
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7146
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7147 if(thisbox->count > 1)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7148 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7149 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7150
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7151 /* Copy all but the current entry to the new list */
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7152 for(z=0;z<index;z++)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7153 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7154 tmpitem[z] = thisitem[z];
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7155 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7156 for(z=index+1;z<thisbox->count;z++)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7157 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7158 tmpitem[z-1] = thisitem[z];
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7159 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7160 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7161
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7162 thisbox->items = tmpitem;
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7163 if(thisitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7164 free(thisitem);
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7165 if(tmpitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7166 thisbox->count--;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7167 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7168 thisbox->count = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7169
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7170 SetParent(handle, DW_HWND_OBJECT);
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7171 /* Queue a redraw on the top-level window */
1680
b09f5f73189c On OS/2 and Windows need to use the parent (box) handle not the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1679
diff changeset
7172 _dw_redraw(_toplevel_window(parent), TRUE);
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7173 return DW_ERROR_NONE;
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7174 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7175 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7176 return DW_ERROR_GENERAL;
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7177 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7178
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7179 /*
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7180 * Remove windows (widgets) from a box at an arbitrary location.
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7181 * Parameters:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7182 * box: Window handle of the box to be removed from.
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7183 * index: 0 based index of packed items.
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7184 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7185 * Handle to the removed item on success, 0 on failure or padding.
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7186 */
1769
d81bebc5c8cc Mark and I decided to change dw_box_remove*() to dw_box_unpack*() for consistency.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1766
diff changeset
7187 HWND API dw_box_unpack_at_index(HWND box, int index)
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7188 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7189 Box *thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA);
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7190
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7191 /* Try to remove it from the layout */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7192 if(thisbox && index > -1 && index < thisbox->count)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7193 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7194 int z;
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7195 Item *tmpitem = NULL, *thisitem = thisbox->items;
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7196 HWND handle = thisitem[index].hwnd;
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7197
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7198 if(thisbox->count > 1)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7199 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7200 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7201
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7202 /* Copy all but the current entry to the new list */
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7203 for(z=0;z<index;z++)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7204 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7205 tmpitem[z] = thisitem[z];
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7206 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7207 for(z=index+1;z<thisbox->count;z++)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7208 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7209 tmpitem[z-1] = thisitem[z];
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7210 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7211 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7212
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7213 thisbox->items = tmpitem;
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7214 if(thisitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7215 free(thisitem);
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7216 if(tmpitem)
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7217 thisbox->count--;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7218 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7219 thisbox->count = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7220
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7221 /* If it isn't padding, reset the parent */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7222 if(handle)
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7223 SetParent(handle, DW_HWND_OBJECT);
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7224 /* Queue a redraw on the top-level window */
1669
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1667
diff changeset
7225 _dw_redraw(_toplevel_window(box), TRUE);
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1667
diff changeset
7226 return handle;
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1667
diff changeset
7227 }
36a090da4cb1 Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1667
diff changeset
7228 return 0;
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7229 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7230
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7231 /*
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7232 * Pack windows (widgets) into a box at an arbitrary location.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7233 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7234 * box: Window handle of the box to be packed into.
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7235 * item: Window handle of the item to pack.
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7236 * index: 0 based index of packed items.
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7237 * width: Width in pixels of the item or -1 to be self determined.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7238 * height: Height in pixels of the item or -1 to be self determined.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7239 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7240 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7241 * pad: Number of pixels of padding around the item.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7242 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7243 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7244 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7245 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7246 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7247
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7248 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7249 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 * box: Window handle of the box to be packed into.
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7252 * item: Window handle of the item to pack.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7259 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7261 /* 65536 is the table limit on GTK...
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7262 * seems like a high enough value we will never hit it here either.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7263 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7264 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7265 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7266
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7267 /*
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7268 * Pack windows (widgets) into a box from the end (or bottom).
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7269 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7270 * box: Window handle of the box to be packed into.
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7271 * item: Window handle of the item to pack.
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7272 * width: Width in pixels of the item or -1 to be self determined.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7273 * height: Height in pixels of the item or -1 to be self determined.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7274 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7275 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7276 * pad: Number of pixels of padding around the item.
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7277 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7278 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7279 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7280 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 /*
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7284 * The following is an attempt to dynamically size a window based on the size of its
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7285 * children before realization. Only applicable when width or height is less than one.
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7286 */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7287 void _get_window_for_size(HWND handle, unsigned long *width, unsigned long *height)
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7288 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7289 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7290
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7291 if(thisbox)
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7292 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7293 int depth = 0;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
7294 DWORD dwStyle = GetWindowLong(handle, GWL_STYLE);
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
7295 DWORD dwExStyle = GetWindowLong(handle, GWL_EXSTYLE);
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7296 HMENU menu = GetMenu(handle) ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7297 RECT rc = { 0 } ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7298
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7299 /* Calculate space requirements */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7300 _resize_box(thisbox, &depth, *width, *height, 1);
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7301
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7302 rc.right = thisbox->minwidth;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7303 rc.bottom = thisbox->minheight;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7304
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7305 /* Take into account the window border and menu here */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7306 AdjustWindowRectEx(&rc, dwStyle, menu ? TRUE : FALSE, dwExStyle);
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7307
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7308 if ( *width < 1 ) *width = rc.right - rc.left;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7309 if ( *height < 1 ) *height = rc.bottom - rc.top;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7310 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7311 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7312
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7313 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7318 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7320 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7321 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7322 /* Attempt to auto-size */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7323 if ( width < 1 || height < 1 )
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7324 _get_window_for_size(handle, &width, &height);
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: 1436
diff changeset
7325
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: 1436
diff changeset
7326 /* Finally set the size */
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7327 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 /*
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: 1427
diff changeset
7331 * 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: 1427
diff changeset
7332 * 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: 1427
diff changeset
7333 * 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: 1427
diff changeset
7334 * 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: 1427
diff changeset
7335 * 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: 1427
diff changeset
7336 */
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: 1427
diff changeset
7337 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: 1427
diff changeset
7338 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7339 TCHAR tmpbuf[100] = {0};
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: 1528
diff changeset
7340
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7341 GetClassName(handle, tmpbuf, 99);
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7342
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7343 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1) == 0)
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: 1528
diff changeset
7344 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7345 unsigned long thiswidth = 0, thisheight = 0;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7346
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7347 /* Get the size with the border */
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7348 _get_window_for_size(handle, &thiswidth, &thisheight);
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7349
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7350 /* Return what was requested */
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7351 if(width) *width = (int)thiswidth;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7352 if(height) *height = (int)thisheight;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7353 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7354 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0)
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: 1528
diff changeset
7355 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7356 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7357
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7358 if(thisbox)
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7359 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7360 int depth = 0;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7361
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7362 /* Calculate space requirements */
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7363 _resize_box(thisbox, &depth, 0, 0, 1);
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7364
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7365 /* Return what was requested */
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7366 if(width) *width = thisbox->minwidth;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7367 if(height) *height = thisbox->minheight;
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7368 }
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7369 }
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7370 else
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7371 _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: 1427
diff changeset
7372 }
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: 1427
diff changeset
7373
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: 1427
diff changeset
7374 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7377 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7379 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7385 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7387 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 /* This should return the current color depth */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
7391 unsigned long API dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7393 int bpp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7394 HDC hdc = GetDC(HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7395
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7396 bpp = GetDeviceCaps(hdc, BITSPIXEL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7397
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7398 ReleaseDC(HWND_DESKTOP, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7399
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7400 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7403 /*
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7404 * Sets the gravity of a given window (widget).
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7405 * Gravity controls which corner of the screen and window the position is relative to.
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7406 * Parameters:
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7407 * handle: Window (widget) handle.
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7408 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7409 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7410 */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7411 void API dw_window_set_gravity(HWND handle, int horz, int vert)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7412 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7413 dw_window_set_data(handle, "_dw_grav_horz", DW_INT_TO_POINTER(horz));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7414 dw_window_set_data(handle, "_dw_grav_vert", DW_INT_TO_POINTER(vert));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7415 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7416
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7417 /* Convert the coordinates based on gravity */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7418 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7419 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7420 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz"));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7421 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert"));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7422
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7423 /* Do any gravity calculations */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7424 if(horz || vert)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7425 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7426 long newx = *x, newy = *y;
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7427
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7428 /* Handle horizontal center gravity */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7429 if((horz & 0xf) == DW_GRAV_CENTER)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7430 newx += ((dw_screen_width() / 2) - (width / 2));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7431 /* Handle right gravity */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7432 else if((horz & 0xf) == DW_GRAV_RIGHT)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7433 newx = dw_screen_width() - width - *x;
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7434 /* Handle vertical center gravity */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7435 if((vert & 0xf) == DW_GRAV_CENTER)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7436 newy += ((dw_screen_height() / 2) - (height / 2));
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7437 else if((vert & 0xf) == DW_GRAV_BOTTOM)
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7438 newy = dw_screen_height() - height - *y;
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7439
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7440 /* Save the new values */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7441 *x = newx;
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7442 *y = newy;
1493
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7443
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7444 /* Adjust the values to avoid Taskbar if requested */
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7445 if((horz | vert) & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7446 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7447 POINT pt = { 0, 0 };
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7448 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7449 MONITORINFO mi;
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7450
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7451 mi.cbSize = sizeof(MONITORINFO);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7452
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7453 GetMonitorInfo(mon, &mi);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7454
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7455 if(horz & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7456 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7457 if((horz & 0xf) == DW_GRAV_LEFT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7458 *x += (mi.rcWork.left - mi.rcMonitor.left);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7459 else if((horz & 0xf) == DW_GRAV_RIGHT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7460 *x -= (mi.rcMonitor.right - mi.rcWork.right);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7461 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7462 if(vert & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7463 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7464 if((vert & 0xf) == DW_GRAV_TOP)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7465 *y += (mi.rcWork.top - mi.rcMonitor.top);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7466 else if((vert & 0xf) == DW_GRAV_BOTTOM)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7467 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7468 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7469 }
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7470 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7471 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7480 void API dw_window_set_pos(HWND handle, long x, long y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7482 unsigned long width, height;
1498
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7483 RECT rect;
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7484
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7485 GetClientRect(handle, &rect);
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7486
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7487 /* 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: 1493
diff changeset
7488 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0)
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7489 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: 1493
diff changeset
7490
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7491 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7492 _handle_gravity(handle, &x, &y, width, height);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7493 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7505 void API dw_window_set_pos_size(HWND handle, long x, long y, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7506 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7507 /* Attempt to auto-size */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7508 if ( width < 1 || height < 1 )
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7509 _get_window_for_size(handle, &width, &height);
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: 1436
diff changeset
7510
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7511 _handle_gravity(handle, &x, &y, width, height);
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: 1436
diff changeset
7512 /* Finally set the size */
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7513 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7523 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7524 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7525 void API dw_window_get_pos_size(HWND handle, long *x, long *y, ULONG *width, ULONG *height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7526 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7527 WINDOWPLACEMENT wp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7528
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7529 wp.length = sizeof(WINDOWPLACEMENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7530
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7531 GetWindowPlacement(handle, &wp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7532 if( wp.showCmd == SW_SHOWMAXIMIZED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7533 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7534 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7535 *x=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7536 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7537 *y=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7538 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7539 *width=dw_screen_width();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7540 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7541 *height=dw_screen_height();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7542 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7543 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7544 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7545 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7546 *x = wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7547 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7548 *y = wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7549 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7550 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7551 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7552 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7553 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7563 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 {
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7565 ULONG tmp, currentstyle;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7566 ColorInfo *cinfo;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7567 TCHAR tmpbuf[100] = {0};
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7568
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7569 if(!handle || !mask)
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7570 return;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7571
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7572 if(handle < (HWND)65536)
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7573 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7574 char buffer[31] = {0};
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7575 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
7576 ULONG id = (ULONG)(uintptr_t)handle;
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7577
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7578 _snprintf(buffer, 30, "_dw_id%ld", id);
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7579 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer);
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7580
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7581 if(mymenu && IsMenu(mymenu))
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7582 dw_menu_item_set_state((HMENUI)mymenu, id, style & mask);
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7583 return;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7584 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7585
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7586 GetClassName(handle, tmpbuf, 99);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7587
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7588 currentstyle = GetWindowLong(handle, GWL_STYLE);
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7589 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7590
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7591 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7592 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7593 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7594 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7595 ULONG thisstyle = (TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7596
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7597 if(mask & DW_BS_NOBORDER)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7598 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7599 SetWindowLong(handle, GWL_STYLE, (style & DW_BS_NOBORDER) ? (currentstyle | thisstyle) : (currentstyle & ~thisstyle));
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
7600
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
7601 /* Enable or disable visual themese */
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
7602 if(_SetWindowTheme)
1750
1de7daad85a3 Updated readme, removed debug message and committed fixes for ANSI builds on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1749
diff changeset
7603 _SetWindowTheme(handle, (style & DW_BS_NOBORDER) ? NULL : L"", (style & DW_BS_NOBORDER) ? NULL : L"");
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
7604
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7605 return;
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7606 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7607 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7608 #endif
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7609
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7610 tmp = currentstyle | mask;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7611 tmp ^= mask;
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7612 tmp |= style & mask;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7613
1804
83b2bd4ca2a3 Drop out of dw_window_set_style() on Windows for status text widgets...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1803
diff changeset
7614 /* Drop out for status bar, it currently doesn't accept styles on Windows */
83b2bd4ca2a3 Drop out of dw_window_set_style() on Windows for status text widgets...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1803
diff changeset
7615 if(_tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1)==0)
83b2bd4ca2a3 Drop out of dw_window_set_style() on Windows for status text widgets...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1803
diff changeset
7616 return;
83b2bd4ca2a3 Drop out of dw_window_set_style() on Windows for status text widgets...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1803
diff changeset
7617 else if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7618 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7619 tmp = tmp & 0xffff0000;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7620 #ifdef AEROGLASS
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7621 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7622 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
7623 LONG_PTR styleex = GetWindowLongPtr(handle, GWL_EXSTYLE);
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7624
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7625 if(style & DW_FCF_COMPOSITED)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7626 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7627 MARGINS mar = {-1};
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7628
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7629 /* Attempt to enable Aero glass background on the entire window */
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7630 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex | WS_EX_LAYERED);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7631 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7632 _DwmExtendFrameIntoClientArea(handle, &mar);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7633 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7634 else
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7635 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7636 MARGINS mar = {0};
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7637
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7638 /* Remove Aero Glass */
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7639 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7640 _DwmExtendFrameIntoClientArea(handle, &mar);
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7641 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7642 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7643 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7644 }
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7645 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7646 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7647 ULONG thismask = mask & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7648 ULONG thisstyle = style & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7649 ULONG type = style & mask & 0xFL;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7650
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7651 /* Need to filter out bits that shouldn't be set */
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7652 tmp = currentstyle | thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7653 tmp ^= thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7654 tmp |= thisstyle & thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7655
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7656 if(mask & DW_DT_VCENTER)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7657 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7658 if(style & DW_DT_VCENTER)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7659 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7660 if(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7661 cinfo->vcenter = 1;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7662 else
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7663 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7664 cinfo = calloc(1, sizeof(ColorInfo));
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7665 cinfo->fore = cinfo->back = -1;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7666 cinfo->vcenter = 1;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7667
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7668 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7669 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7670 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7671 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7672 else if(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7673 cinfo->vcenter = 0;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7674 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7675 /* Alignment style is 0 for word wrap */
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7676 if((style & DW_DT_WORDBREAK) && (mask & DW_DT_WORDBREAK))
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7677 tmp &= ~(0xFL);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7678 else if(type == SS_LEFTNOWORDWRAP)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7679 tmp = (tmp & ~(0xFL)) | SS_LEFTNOWORDWRAP;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7680 else if(type == SS_CENTER)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7681 tmp = (tmp & ~(0xFL)) | SS_CENTER;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7682 else if(type == SS_RIGHT)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7683 tmp = (tmp & ~(0xFL)) | SS_RIGHT;
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7684 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7685
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7686 SetWindowLong(handle, GWL_STYLE, tmp);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7687 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7688
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7689 /* Finds the physical ID from the reference ID */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7690 int _findnotebookid(NotebookPage **array, int pageid)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7691 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7692 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7693
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7694 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7695 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7696 if(array[z] && array[z]->realid == pageid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7697 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7698 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7699 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7709 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7711 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7712
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7713 if(array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7714 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7715 int z, refid = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7716
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7717 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7718 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7719 if(_findnotebookid(array, z) == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7720 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7721 refid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7722 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7723 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7724 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7725
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7726 if(refid == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7727 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7729 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7730 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7731 if(!array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7732 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7733 array[z] = calloc(1, sizeof(NotebookPage));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7734 array[z]->realid = refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7735 array[z]->item.mask = TCIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7736 array[z]->item.iImage = -1;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7737 array[z]->item.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7738 TabCtrl_InsertItem(handle, z, &(array[z]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7739 return refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7740 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7741 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7742 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7743 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7746 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7752 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7753 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7754 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7755
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7756 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7757 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7758
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7759 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7760 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7761
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7762 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7763
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7764 if(pageid > -1 && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7765 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7766 array[pageid]->item.mask = TCIF_TEXT;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7767 array[pageid]->item.pszText = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7768 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7769 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7770 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7771 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7772
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7773 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7780 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7781 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7782 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7783
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7786 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7788 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7789 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7791 void API dw_notebook_pack(HWND handle, ULONG pageidx, HWND page)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7792 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7793 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7794 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7795
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7796 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7797 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7798
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7799 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7800
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7801 if(pageid > -1 && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7802 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7803 HWND tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7804
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7805 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7806 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7807 dw_window_destroy(array[pageid]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7808 array[pageid]->hwnd = tmpbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7809 if(pageidx == dw_notebook_page_get(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7810 {
913
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
7811 ShowWindow(tmpbox, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7812 SetParent(tmpbox, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7813 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7814 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7815 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7816 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7817
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7818 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7819 * Remove a page from a notebook.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7820 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7821 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7822 * pageid: ID of the page to be destroyed.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7823 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7824 void API dw_notebook_page_destroy(HWND handle, unsigned int pageidx)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7825 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7826 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7827 int newid = -1, z, pageid;
1331
4c12170f003f Make dw_notebook_page_destroy() on OS/2 and Windows destroy the contents of the page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
7828 HWND pagehwnd = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7829
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7830 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7831 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7833 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7835 if(pageid < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7836 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7837
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7838 if(array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7839 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7840 SetParent(array[pageid]->hwnd, DW_HWND_OBJECT);
1331
4c12170f003f Make dw_notebook_page_destroy() on OS/2 and Windows destroy the contents of the page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
7841 pagehwnd = array[pageid]->hwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7842 free(array[pageid]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7843 array[pageid] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7844 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7846 TabCtrl_DeleteItem(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7847
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7848 /* Shift the pages over 1 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7849 for(z=pageid;z<255;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7850 array[z] = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7851 array[255] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7853 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7854 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7855 if(array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7856 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7857 newid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7858 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7859 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7860 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7861 if(newid > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7862 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7863 SetParent(array[newid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7864 _resize_notebook_page(handle, newid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7865 dw_notebook_page_set(handle, array[newid]->realid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7866 }
1331
4c12170f003f Make dw_notebook_page_destroy() on OS/2 and Windows destroy the contents of the page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
7867 if(pagehwnd)
4c12170f003f Make dw_notebook_page_destroy() on OS/2 and Windows destroy the contents of the page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1322
diff changeset
7868 dw_window_destroy(pagehwnd);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7869 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7870
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7871 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7872 * Queries the currently visible page ID.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7873 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7874 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7875 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7876 unsigned long API dw_notebook_page_get(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7877 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7878 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7879 int physid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7880
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7881 if(physid > -1 && physid < 256 && array && array[physid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7882 return array[physid]->realid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7883 return -1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7884 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7885
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7886 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7887 * Sets the currently visible page ID.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7888 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7889 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7890 * pageid: ID of the page to be made visible.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7891 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7892 void API dw_notebook_page_set(HWND handle, unsigned int pageidx)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7893 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7894 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7895 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7896
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7897 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7898 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7899
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7900 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7901
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7902 if(pageid > -1 && pageid < 256)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7903 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7904 int oldpage = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7905
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7906 if(oldpage > -1 && array && array[oldpage])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7907 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7909 TabCtrl_SetCurSel(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7910
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7911 SetParent(array[pageid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7912 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7913 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7922 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7924 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7926 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7927
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7928 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7929 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7930 CB_ADDSTRING,
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7931 0, (LPARAM)UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7932 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7933 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7934 LB_ADDSTRING,
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7935 0, (LPARAM)UTF8toWide(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7937
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7938 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7939 * Appends the specified text items to the listbox's (or combobox) entry list.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7940 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7941 * handle: Handle to the listbox to be appended to.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7942 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7943 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7944 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7945 void API dw_listbox_list_append(HWND handle, char **text, int count)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7946 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7947 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7948 int listbox_type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7949 int i;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7951 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7952
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7953 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7954 listbox_type = CB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7955 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7956 listbox_type = LB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7957
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7958 for(i=0;i<count;i++)
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7959 SendMessage(handle,(WPARAM)listbox_type,0,(LPARAM)UTF8toWide(text[i]));
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7960 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7961
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7962 /*
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7963 * Inserts the specified text to the listbox's (or combobox) entry list.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7964 * Parameters:
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7965 * handle: Handle to the listbox to be appended to.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7966 * text: Text to append into listbox.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7967 * pos: 0 based position to insert text
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7968 */
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7969 void API dw_listbox_insert(HWND handle, char *text, int pos)
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7970 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7971 TCHAR tmpbuf[100] = {0};
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7972
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7973 GetClassName(handle, tmpbuf, 99);
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7974
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7975 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7976 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7977 CB_INSERTSTRING,
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7978 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7979 else
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7980 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7981 LB_INSERTSTRING,
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7982 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7983 }
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7984
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7985 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7990 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7992 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7993
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7994 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7995
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7996 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7997 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7998 char *buf = dw_window_get_text(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7999
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8000 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8001 CB_RESETCONTENT, 0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8002
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8003 if(buf)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8004 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8005 dw_window_set_text(handle, buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8006 free(buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8007 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8008 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8009 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8010 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8011 LB_RESETCONTENT, 0L, 0L);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8012 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8013
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8014 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8015 * Sets the text of a given listbox entry.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8016 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8017 * handle: Handle to the listbox to be queried.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8018 * index: Index into the list to be queried.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8019 * buffer: Buffer where text will be copied.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8020 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8021 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8022 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8023 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8024
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8025 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8026
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8027 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8028 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8029 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8030 SendMessage(handle, CB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8031 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8032 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8033 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8034 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8035 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8036 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8037 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8038 SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8039 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8048 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8050 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8051 {
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8052 TCHAR tmpbuf[100] = {0}, *wbuffer;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
8053 unsigned int len;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8054
1623
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8055 buffer[0] = 0;
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8056
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8057 if(!buffer || !length)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8058 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8059
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8060 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8061
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8062 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8063 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8064 len = (int)SendMessage(handle, CB_GETLBTEXTLEN, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8065
1623
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8066 if(len != CB_ERR && (wbuffer = _alloca((len+1)*sizeof(TCHAR))))
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8067 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8068 SendMessage(handle, CB_GETLBTEXT, (WPARAM)index, (LPARAM)wbuffer);
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8069 strncpy(buffer, WideToUTF8(wbuffer), length);
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8070 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8071 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8072 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8073 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8074 len = (int)SendMessage(handle, LB_GETTEXTLEN, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8075
1623
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8076 if(len != LB_ERR && (wbuffer = _alloca((len+1)*sizeof(TCHAR))))
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8077 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8078 SendMessage(handle, LB_GETTEXT, (WPARAM)index, (LPARAM)wbuffer);
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8079 strncpy(buffer, WideToUTF8(wbuffer), length);
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8080 }
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8081 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8087 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 */
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: 975
diff changeset
8089 int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8091 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8092
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8093 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8094
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8095 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8096 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8097 CB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8098 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8099
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8100 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8101 LB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8102 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8105 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8111 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8112 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8113 int *array, count, z;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8114 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8115
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8116 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8117
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8118 /* This doesn't work on comboboxes */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8119 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8120 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8121
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8122 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8123 if(count > 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8124 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8125 array = malloc(sizeof(int)*count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8126 SendMessage(handle, LB_GETSELITEMS, (WPARAM)count, (LPARAM)array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8127
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8128 if(where == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8129 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8130 int ret = array[0];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8131 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8132 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8133 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8134 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8135 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8136 if(array[z] == where && (z+1) < count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8137 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8138 int ret = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8139 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8140 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8141 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8142 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8143 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8144 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8145 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8155 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8157 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8158
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8159 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8160
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8161 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8162 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8163 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8164 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8165 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8166 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8167 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8168 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8177 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8179 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8180
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8181 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8182
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8183 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8184 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8185 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8186 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8187 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8188
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8189 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8190 * Returns the listbox's item count.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8191 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8192 * handle: Handle to the listbox to be cleared.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8193 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8194 int API dw_listbox_count(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8195 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8196 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8197
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8198 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8199
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8200 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8201 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8202 CB_GETCOUNT,0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8203
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8204 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8205 LB_GETCOUNT,0L, 0L);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8206 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8207
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8208 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8209 * Sets the topmost item in the viewport.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8210 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8211 * handle: Handle to the listbox to be cleared.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8212 * top: Index to the top item.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8213 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8214 void API dw_listbox_set_top(HWND handle, int top)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8215 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8216 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8217
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8218 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8219
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8220 /* This doesn't work on comboboxes */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8221 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8222 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8223
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8224 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8225 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8226
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8234 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8236 int textlen, len = GetWindowTextLength(handle);
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8237 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8238
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8239 if(startpoint < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8240 startpoint = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8241
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8242 if(!buffer || (textlen = (int)_tcslen(srcbuf)) < 1)
997
dfa2204e231f Fixes for dw_mle_import to make it function like the other platforms on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
8243 return startpoint;
dfa2204e231f Fixes for dw_mle_import to make it function like the other platforms on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
8244
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8245 tmpbuf = calloc(sizeof(TCHAR), len + textlen + startpoint + 2);
997
dfa2204e231f Fixes for dw_mle_import to make it function like the other platforms on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
8246
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8247 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8248 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8249 TCHAR *dest, *start;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8250 int copylen = len - startpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8251
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8252 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8253
997
dfa2204e231f Fixes for dw_mle_import to make it function like the other platforms on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
8254 dest = &tmpbuf[startpoint+textlen];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8255 start = &tmpbuf[startpoint];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8256
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8257 if(copylen > 0)
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8258 memcpy(dest, start, copylen*sizeof(TCHAR));
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8259 }
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8260 memcpy(&tmpbuf[startpoint], srcbuf, textlen*sizeof(TCHAR));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8261
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8262 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8263
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8264 free(tmpbuf);
997
dfa2204e231f Fixes for dw_mle_import to make it function like the other platforms on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 986
diff changeset
8265 return (startpoint + textlen);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8270 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 * handle: Handle to the MLE to be queried.
608
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 593
diff changeset
8272 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8274 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8275 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8276 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8277 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8278 int max, len = GetWindowTextLength(handle);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8279 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8280
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8281 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8282 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8284 buffer[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8285
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8286 if(startpoint < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8287 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8288 max = MIN(length, len - startpoint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8289
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8290 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8291 buffer[max] = '\0';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8292 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8293
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8294 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8302 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8304 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8305 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8306 if(bytes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8307 *bytes = GetWindowTextLength(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8308 if(lines)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8309 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8319 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8321 int len = GetWindowTextLength(handle);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8322 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8323
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8324 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8325
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8326 if(startpoint + length < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8327 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8328 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8329
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8330 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8331 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8332
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8333 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8334 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8337 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8339 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8340 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8341 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8343 SetWindowText(handle, TEXT(""));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8344 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 * Parameters:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8349 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8350 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8352 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8354 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8355 dw_mle_set_cursor(handle, point);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8358 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8359 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8360 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8361 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8362 * state: TRUE if it can be edited, FALSE for readonly.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8363 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8364 void API dw_mle_set_editable(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8365 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8366 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8367 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8368
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8369 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8370 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8371 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8372 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8373 * state: TRUE if it wraps, FALSE if it doesn't.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8374 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8375 void API dw_mle_set_word_wrap(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8376 {
1541
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
8377 /* If ES_AUTOHSCROLL is not set and there is no
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8378 * horizontal scrollbar it word wraps.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8379 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8380 if(state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8381 dw_window_set_style(handle, 0, ES_AUTOHSCROLL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8382 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8383 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL);
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8384 /* If it is a rich edit control use the rich edit message */
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8385 if(hrichedit)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8386 {
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8387 if(state)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8388 SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_AND, (LPARAM)~ECO_AUTOHSCROLL);
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8389 else
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8390 SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_OR, (LPARAM)ECO_AUTOHSCROLL);
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8391 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8392 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8393
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8394 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8400 void API dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401 {
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8402 SendMessage(handle, EM_SETSEL, 0, MAKELPARAM(point,point));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8403 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8412 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8414 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8415 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8416 int len = GetWindowTextLength(handle);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8417 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8418 TCHAR *searchtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8419 int z, textlen, retval = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8420
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8421 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8422
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
8423 textlen = (int)strlen(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8424
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8425 if(flags & DW_MLE_CASESENSITIVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8426 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8427 for(z=point;z<(len-textlen) && !retval;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8428 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8429 if(_tcsncmp(&tmpbuf[z], searchtext, textlen) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8430 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8431 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8432 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8433 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8434 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8435 for(z=point;z<(len-textlen) && !retval;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8436 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8437 if(_tcsnicmp(&tmpbuf[z], searchtext, textlen) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8438 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8439 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8440 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8441
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8442 if(retval)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8443 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8444 SendMessage(handle, EM_SETSEL, (WPARAM)retval - textlen, (LPARAM)retval);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8445 SendMessage(handle, EM_SCROLLCARET, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8446 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8447
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8448 free(tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8449
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8450 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8453 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8458 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8459 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8460 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8467 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
8472 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8473 * Parameters:
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8474 * handle: Handle to the percent bar to be set.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8475 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8477 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8478 {
1190
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8479 if(position == DW_PERCENT_INDETERMINATE)
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8480 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8481 /* If our common controls supports it... */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8482 if((dwComctlVer >= PACKVERSION(6,0)))
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8483 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8484 /* Enable the style on the control */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8485 SetWindowLong(handle, GWL_STYLE, GetWindowLong(handle, GWL_STYLE) | PBS_MARQUEE);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8486 /* Start the bar going */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8487 SendMessage(handle, PBM_SETMARQUEE, 1, 100);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8488 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8489 else
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8490 SendMessage(handle, PBM_SETPOS, 0, 0);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8491 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8492 else
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8493 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8494 if((dwComctlVer >= PACKVERSION(6,0)))
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8495 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8496 unsigned long style = GetWindowLong(handle, GWL_STYLE);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8497
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8498 if(style & PBS_MARQUEE)
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8499 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8500 /* Stop the bar */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8501 SendMessage(handle, PBM_SETMARQUEE, 0, 0);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8502 /* Disable the style on the control */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8503 SetWindowLong(handle, GWL_STYLE, style & ~PBS_MARQUEE);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8504 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8505 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8506 /* Otherwise just set the position */
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8507 SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0);
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8508 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8512 * Returns the position of the slider.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8513 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8514 * handle: Handle to the slider to be queried.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8515 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8516 unsigned int API dw_slider_get_pos(HWND handle)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8517 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8518 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8519 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8520
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8521 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8522 return max - (unsigned int)SendMessage(handle, TBM_GETPOS, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8523 return (unsigned int)SendMessage(handle, TBM_GETPOS, 0, 0);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8524 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8525
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8526 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8527 * Sets the slider position.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8528 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8529 * handle: Handle to the slider to be set.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8530 * position: Position of the slider withing the range.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8531 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8532 void API dw_slider_set_pos(HWND handle, unsigned int position)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8533 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8534 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8535 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8536
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8537 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8538 SendMessage(handle, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)max - position);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8539 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8540 SendMessage(handle, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)position);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8541 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8542
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8543 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8544 * Returns the position of the scrollbar.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8545 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8546 * handle: Handle to the scrollbar to be queried.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8547 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8548 unsigned int API dw_scrollbar_get_pos(HWND handle)
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8549 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8550 return (unsigned int)SendMessage(handle, SBM_GETPOS, 0, 0);
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8551 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8552
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8553 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8554 * Sets the scrollbar position.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8555 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8556 * handle: Handle to the scrollbar to be set.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8557 * position: Position of the scrollbar withing the range.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8558 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8559 void API dw_scrollbar_set_pos(HWND handle, unsigned int position)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8560 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
8561 dw_window_set_data(handle, "_dw_scrollbar_value", DW_UINT_TO_POINTER(position));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8562 SendMessage(handle, SBM_SETPOS, (WPARAM)position, (LPARAM)TRUE);
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8563 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8564
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8565 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8566 * Sets the scrollbar range.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8567 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8568 * handle: Handle to the scrollbar to be set.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8569 * range: Maximum range value.
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8570 * visible: Visible area relative to the range.
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8571 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8572 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8573 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8574 SCROLLINFO si;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8575
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8576 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8577 si.fMask = SIF_RANGE | SIF_PAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8578 si.nMin = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8579 si.nMax = range - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8580 si.nPage = visible;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8581 SendMessage(handle, SBM_SETSCROLLINFO, (WPARAM)TRUE, (LPARAM)&si);
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8582 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8583
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8584 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8588 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8590 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8591 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8592 TCHAR tmpbuf[101] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8593 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8594
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8595 _sntprintf(tmpbuf, 100, TEXT("%ld"), position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8596
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8597 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8598 SetWindowText(cinfo->buddy, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8599
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
8600 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 * handle: Handle to the spinbutton to be set.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8607 * position: Current value of the spinbutton.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8608 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8610 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 {
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
8612 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8621 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8623 SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8624 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8629 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8631 long API dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 {
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
8633 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8637 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8639 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8640 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8641 int API dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8642 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8643 if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8644 return (in_checkbox_handler ? FALSE : TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8645 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8647
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8648 /* This function unchecks all radiobuttons on a box */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8649 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8650 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8651 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8652
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8653 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8654
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8655 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8656 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8657 if(!dw_window_get_data(handle, "_dw_checkbox"))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8658 SendMessage(handle, BM_SETCHECK, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8659 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8660 return TRUE;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8661 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8662 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8663 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8664 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8665 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8666 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8667 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8668 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8669 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8670 if(!dw_window_get_data(handle, "_dw_checkbox"))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8671 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8672 HWND parent = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8673
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8674 if(parent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8675 EnumChildWindows(parent, _uncheck_radios, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8676 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8677 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8680 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8681 * Inserts an item into a tree window (widget) after another item.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8682 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8683 * handle: Handle to the tree to be inserted.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8684 * item: Handle to the item to be positioned after.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8685 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8686 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8687 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8688 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8689 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
8690 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8691 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8692 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8693 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8694 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8695 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8696
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8697 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8698 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8699
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8700 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8701 tvi.pszText = UTF8toWide(title);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8702 tvi.lParam = (LPARAM)ptrs;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8703 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8704 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8705
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8706 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8707 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8708 tvins.hInsertAfter = item ? item : TVI_FIRST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8709
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8710 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8711
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8712 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8713 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8714
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8715 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8716 * Inserts an item into a tree window (widget).
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8717 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8718 * handle: Handle to the tree to be inserted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8719 * title: The text title of the entry.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8720 * icon: Handle to coresponding icon.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8721 * parent: Parent handle or 0 if root.
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8722 * itemdata: Item specific data.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8723 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
8724 HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8725 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8726 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8727 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8728 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8729 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8730
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8731 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8732 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8733
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8734 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8735 tvi.pszText = UTF8toWide(title);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8736 tvi.lParam = (LPARAM)ptrs;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8737 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8738 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8739
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8740 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8741 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8742 tvins.hInsertAfter = TVI_LAST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8743
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8744 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8745
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8746 return hti;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8747 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8748
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8749 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8750 * Sets the text and icon of an item in a tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8751 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8752 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8753 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8754 * title: The text title of the entry.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8755 * icon: Handle to coresponding icon.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8756 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
8757 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8758 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8759 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8760 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8761
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8762 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8763 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8764
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8765 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8766 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8767
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8768 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8769 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8770
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8771 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8772 tvi.pszText = UTF8toWide(title);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8773 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8774 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8775 tvi.hItem = (HTREEITEM)item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8776
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8777 TreeView_SetItem(handle, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8778 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8779 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8780
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8781 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8782 * Sets the item data of a tree item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8783 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8784 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8785 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8786 * itemdata: User defined data to be associated with item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8787 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8788 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8789 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8790 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8791 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8792
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8793 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8794 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8795
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8796 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8797 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8798 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8799 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8800 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8801 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8802
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8803 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8804 * Gets the item data of a tree item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8805 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8806 * handle: Handle to the tree containing the item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8807 * item: Handle of the item to be modified.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8808 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8809 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8810 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8811 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8812 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8813
1062
28e63fe64167 Minor changes to the tree handling... added the LVIF_PARAM to make sure that member gets filled in on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1060
diff changeset
8814 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8815 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8816
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8817 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8818 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8819 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8820 return ptrs[1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8821 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8822 return NULL;
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8823 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8824
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8825 /*
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8826 * Gets the text an item in a tree window (widget).
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8827 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8828 * handle: Handle to the tree containing the item.
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8829 * item: Handle of the item to be modified.
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8830 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8831 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8832 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8833 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8835 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8836 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8837
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8838 if(TreeView_GetItem(handle, &tvi))
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
8839 return _strdup(WideToUTF8(tvi.pszText));
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8840 return NULL;
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8841 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8842
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8843 /*
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8844 * Gets the text an item in a tree window (widget).
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8845 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8846 * handle: Handle to the tree containing the item.
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8847 * item: Handle of the item to be modified.
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8848 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8849 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8850 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8851 return TreeView_GetParent(handle, item);
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8852 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8853
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8854 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8855 * Sets this item as the active selection.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8856 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8857 * handle: Handle to the tree window (widget) to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8858 * item: Handle to the item to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8859 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
8860 void API dw_tree_item_select(HWND handle, HTREEITEM item)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8861 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8862 TreeView_SelectItem(handle, item);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8863 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8864
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8865 /* Delete all tree subitems */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8866 void _dw_tree_item_delete_recursive(HWND handle, HTREEITEM node)
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8867 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8868 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8869
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8870 hti = TreeView_GetChild(handle, node);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8871
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8872 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8873 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8874 HTREEITEM lastitem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8875
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8876 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8877 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8878 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8879 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8880
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8881 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8882 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8883 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8884 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8885 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8886 void API dw_tree_clear(HWND handle)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8887 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8888 HTREEITEM hti = TreeView_GetRoot(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8889
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8890 dw_window_set_data(handle, "_dw_select_item", (void *)1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8891 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8892 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8893 HTREEITEM lastitem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8894
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8895 _dw_tree_item_delete_recursive(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8896 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8897 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8898 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8899 dw_window_set_data(handle, "_dw_select_item", (void *)0);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8900 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8901
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8902 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8903 * Expands a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8904 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8905 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8906 * item: Handle to node to be expanded.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8907 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8908 void API dw_tree_item_expand(HWND handle, HTREEITEM item)
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
8909 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8910 TreeView_Expand(handle, item, TVE_EXPAND);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8911 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8912
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8913 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8914 * Collapses a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8915 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8916 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8917 * item: Handle to node to be collapsed.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8918 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8919 void API dw_tree_item_collapse(HWND handle, HTREEITEM item)
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
8920 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8921 TreeView_Expand(handle, item, TVE_COLLAPSE);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8922 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8923
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8924 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8925 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8926 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8927 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8928 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8929 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8930 void API dw_tree_item_delete(HWND handle, HTREEITEM item)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8931 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8932 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8933 void **ptrs=NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8934
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8935 if(item == TVI_ROOT || !item)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8936 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8937
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8938 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8939 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8940
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8941 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8942 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8943
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8944 _dw_tree_item_delete_recursive(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8945 TreeView_DeleteItem(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8946 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8947 free(ptrs);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8948 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8949
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8950 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8955 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8956 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8957 * separator: The column number that contains the main separator.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8958 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8959 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8960 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8961 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8962 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8963 int z, l = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8964 unsigned long *tempflags = calloc(sizeof(unsigned long), count + 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8965 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8966
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8967 if(separator == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8968 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8969 tempflags[0] = DW_CFA_RESERVED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8970 l = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8971 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8972
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8973 memcpy(&tempflags[l], flags, sizeof(unsigned long) * count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8974 tempflags[count + l] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8975 cinfo->flags = tempflags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8976 cinfo->columns = count + l;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8977
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8978
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8979 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8980 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8981 if(titles[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8982 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8983 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8984 lvc.pszText = UTF8toWide(titles[z]);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8985 lvc.cchTextMax = (int)_tcslen(lvc.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8986 if(flags[z] & DW_CFA_RIGHT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8987 lvc.fmt = LVCFMT_RIGHT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8988 else if(flags[z] & DW_CFA_CENTER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8989 lvc.fmt = LVCFMT_CENTER;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8990 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8991 lvc.fmt = LVCFMT_LEFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8992 lvc.cx = 75;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8993 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8994 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8995 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8996 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8997 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
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: 975
diff changeset
8998 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8999 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9000
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9001 /*
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9002 * Configures the main filesystem column title for localization.
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9003 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9004 * 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: 1732
diff changeset
9005 * 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: 1732
diff changeset
9006 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9007 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: 1732
diff changeset
9008 {
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
9009 char *newtitle = _strdup(title ? title : "");
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9010
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9011 dw_window_set_data(handle, "_dw_coltitle", newtitle);
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9012 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9013
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9014 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9015 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9017 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9018 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9019 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9020 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9021 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9022 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9023 {
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9024 char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9025 LV_COLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9026
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9027 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9028 lvc.pszText = coltitle ? UTF8toWide(coltitle) : TEXT("Filename");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9029 lvc.cchTextMax = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9030 lvc.fmt = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9031 if(!count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9032 lvc.cx = 300;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9033 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9034 lvc.cx = 150;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9035 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9036 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9037 dw_container_setup(handle, flags, titles, count, -1);
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9038 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9039 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9040 dw_window_set_data(handle, "_dw_coltitle", NULL);
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9041 free(coltitle);
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9042 }
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: 975
diff changeset
9043 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9053 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9054 HICN API dw_icon_load(unsigned long module, unsigned long id)
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9055 {
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9056 return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9057 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9058
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9059 /*
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9060 * Obtains an icon from a file.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9061 * Parameters:
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9062 * filename: Name of the file, omit extention to have
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9063 * DW pick the appropriate file extension.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9064 * (ICO on OS/2 or Windows, XPM on Unix)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9065 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9066 HICN API dw_icon_load_from_file(char *filename)
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9067 {
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9068 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9069 return _dw_load_icon(filename);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9070 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9071 char *file = malloc(strlen(filename) + 5);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9072 HANDLE icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9073
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9074 if(!file)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9075 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9076
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9077 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9078
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9079 /* check if we can read from this file (it exists and read permission) */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9080 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9081 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9082 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9083 strcat(file, ".ico");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9084 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9085 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9086 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9087 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9088 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9089 }
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9090 icon = LoadImage(NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9091 free(file);
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9092 return (HICN)icon;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9093 #endif
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9094 }
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9095
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
9096 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9097 * Obtains an icon from data
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9098 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9099 * data: Source of icon data
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9100 * DW pick the appropriate file extension.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9101 * (ICO on OS/2 or Windows, XPM on Unix)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9102 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9103 HICN API dw_icon_load_from_data(char *data, int len)
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9104 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
9105 HANDLE icon = 0;
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9106 char *file;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9107 FILE *fp;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9108
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9109 if ( !data )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9110 return 0;
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
9111 file = _tempnam( _dw_alternate_temp_dir, "dw" );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9112 if ( file != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9113 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9114 fp = fopen( file, "wb" );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9115 if ( fp != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9116 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9117 fwrite( data, 1, len, fp );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9118 fclose( fp );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9119 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9120 icon = _dw_load_icon(file);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9121 #else
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9122 icon = LoadImage( NULL, UTF8toWide(file), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
9123 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9124 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9125 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9126 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9127 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
9128 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9129 return 0;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9130 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9131 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
9132 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9133 }
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9134 return (HICN)icon;
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9135 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9136
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9137 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9138 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9142 void API dw_icon_free(HICN handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9144 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9147 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9148 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9149 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9151 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9152 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9153 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9154 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9155 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9156 int z, item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9157
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9158 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9159 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9160 /* Insert at the end */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9161 lvi.iItem = 1000000;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9162 lvi.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9163 lvi.cchTextMax = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9164 lvi.iImage = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9165
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9166 ShowWindow(handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9167 item = ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9168 for(z=1;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9169 ListView_InsertItem(handle, &lvi);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9170 dw_window_set_data(handle, "_dw_insertitem", DW_INT_TO_POINTER(item));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9171 return (void *)handle;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9172 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9173
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9174 /* Finds a icon in the table, otherwise it adds it to the table
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9175 * and returns the index in the table.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9176 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9177 int _lookup_icon(HWND handle, HICON hicon, int type)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9178 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9179 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9180 static HWND lasthwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9181
1508
9b2600034473 Safety check in _lookup_icon() on Windows to make sure we don't try to add an invalid icon handle to the image list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1500
diff changeset
9182 /* We can't add an invalid handle */
9b2600034473 Safety check in _lookup_icon() on Windows to make sure we don't try to add an invalid icon handle to the image list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1500
diff changeset
9183 if(!hicon)
9b2600034473 Safety check in _lookup_icon() on Windows to make sure we don't try to add an invalid icon handle to the image list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1500
diff changeset
9184 return -1;
9b2600034473 Safety check in _lookup_icon() on Windows to make sure we don't try to add an invalid icon handle to the image list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1500
diff changeset
9185
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9186 if(!hSmall || !hLarge)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9187 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9188 hSmall = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9189 hLarge = ImageList_Create(32, 32, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9190 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9191 for(z=0;z<ICON_INDEX_LIMIT;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9192 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9193 if(!lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9194 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9195 lookup[z] = hicon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9196 ImageList_AddIcon(hSmall, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9197 ImageList_AddIcon(hLarge, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9198 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9199 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9200 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9201 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9202 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9203 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9204 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9205 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9206 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9207 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9208 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9209 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9210
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9211 if(hicon == lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9212 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9213 if(lasthwnd != handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9214 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9215 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9216 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9217 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9218 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9219 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9220 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9221 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9222 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9223 }
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9224 lasthwnd = handle;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9225 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9226 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9227 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9228 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9229 return -1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9230 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9231
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9232 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9233 * Sets an item in specified row and column to the given data.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9234 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9235 * handle: Handle to the container window (widget).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9236 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9237 * column: Zero based column of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9238 * row: Zero based row of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9239 * data: Pointer to the data to be added.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9240 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9241 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9242 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9243 LV_ITEM lvi;
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9244 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9245
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9246 if(pointer)
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9247 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9248 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9249 }
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9250
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9251 lvi.iItem = row + item;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9252 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9253 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9254 lvi.pszText = UTF8toWide(filename);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9255 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9256 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9257
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9258 ListView_SetItem(handle, &lvi);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9259 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9260
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9261 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9262 * Sets an item in specified row and column to the given data.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9263 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9264 * handle: Handle to the container window (widget).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9265 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9266 * column: Zero based column of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9267 * row: Zero based row of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9268 * data: Pointer to the data to be added.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9269 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9270 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9271 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9272 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9274
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9276 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9277 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9278 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9279 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9280 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9281 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9282 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9283 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9284 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9285 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9286 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9287 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9288 LV_ITEM lvi;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9289 TCHAR textbuffer[101] = {0};
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9290 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9291
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9292 if(pointer)
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9293 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9294 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9295 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9296
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9297 if(!cinfo || !cinfo->flags)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9298 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9299
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9300 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9301
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9302 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9303 lvi.iItem = row + item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9304 lvi.iSubItem = column;
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9305 lvi.pszText = textbuffer;
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9306 lvi.cchTextMax = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9307
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9308 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9309 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9310 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9311 lvi.pszText = NULL;
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9312
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9313 if(data)
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9314 {
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9315 HICON hicon = *((HICON *)data);
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9316
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9317 lvi.iImage = _lookup_icon(handle, hicon, 0);
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9318 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9319 else
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9320 lvi.iImage = -1;
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9321 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9322 else if(flags[column] & DW_CFA_STRING && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9323 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9324 char *tmp = *((char **)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9325
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9326 if(!tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9327 tmp = "";
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9328
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9329 lvi.pszText = UTF8toWide(tmp);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9330 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9331 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9332 else if(flags[column] & DW_CFA_ULONG && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9333 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9334 ULONG tmp = *((ULONG *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9335
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9336 _sntprintf(textbuffer, 100, TEXT("%lu"), tmp);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9337
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9338 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9339 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9340 else if(flags[column] & DW_CFA_DATE && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9341 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9342 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9343 CDATE cdate = *((CDATE *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9344
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9345 memset(&curtm, 0, sizeof(struct tm));
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9346
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9347 /* Safety check... zero dates are crashing
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9348 * Visual Studio 2008. -Brian
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9349 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9350 if(cdate.year > 1900 && cdate.year < 2100)
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9351 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9352 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9353 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9354 curtm.tm_year = cdate.year - 1900;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9355 _tcsftime(textbuffer, 100, TEXT("%x"), &curtm);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9356 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9357
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9358 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9359 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9360 else if(flags[column] & DW_CFA_TIME && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9361 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9362 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9363 CTIME ctime = *((CTIME *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9364
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9365 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0;
757
d26bfc4cd1f0 Visual Studio 2008's runtime is crazy sensitive. I put in a bunch of parameter checks to make sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 716
diff changeset
9366 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0;
d26bfc4cd1f0 Visual Studio 2008's runtime is crazy sensitive. I put in a bunch of parameter checks to make sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 716
diff changeset
9367 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9368
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9369 _tcsftime(textbuffer, 100, TEXT("%X"), &curtm);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9370
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9371 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9372 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9373
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9374 ListView_SetItem(handle, &lvi);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9375 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9376
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9377 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9378 * Changes an existing item in specified row and column to the given data.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9379 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9380 * handle: Handle to the container window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9381 * column: Zero based column of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9382 * row: Zero based row of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9383 * data: Pointer to the data to be added.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9384 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9385 void API dw_container_change_item(HWND handle, int column, int row, void *data)
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9386 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9387 dw_container_set_item(handle, NULL, column, row, data);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9388 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9389
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9390 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9391 * Changes an existing item in specified row and column to the given data.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9392 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9393 * handle: Handle to the container window (widget).
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9394 * column: Zero based column of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9395 * row: Zero based row of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9396 * data: Pointer to the data to be added.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9397 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9398 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9399 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9400 dw_filesystem_set_item(handle, NULL, column, row, data);
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9401 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9402
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9403 /*
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9404 * Changes an item in specified row and column to the given data.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9405 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9406 * handle: Handle to the container window (widget).
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9407 * pointer: Pointer to the allocated memory in dw_container_alloc().
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9408 * column: Zero based column of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9409 * row: Zero based row of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9410 * data: Pointer to the data to be added.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9411 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9412 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon)
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9414 dw_filesystem_set_file(handle, NULL, row, filename, icon);
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9415 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9416
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9417 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9418 * Gets column type for a container column
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9419 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9420 * handle: Handle to the container window (widget).
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9421 * column: Zero based column.
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9422 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9423 int API dw_container_get_column_type(HWND handle, int column)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9424 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9425 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9426 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9427 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9428
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9429 if(!cinfo || !cinfo->flags)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9430 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9431
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9432 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9433
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9434 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9435 rc = DW_CFA_BITMAPORICON;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9436 else if(flags[column] & DW_CFA_STRING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9437 rc = DW_CFA_STRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9438 else if(flags[column] & DW_CFA_ULONG)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9439 rc = DW_CFA_ULONG;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9440 else if(flags[column] & DW_CFA_DATE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9441 rc = DW_CFA_DATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9442 else if(flags[column] & DW_CFA_TIME)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9443 rc = DW_CFA_TIME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9444 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9445 rc = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9446 return rc;
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9447 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9448
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9449 /*
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9450 * Gets column type for a filesystem container column
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9451 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9452 * handle: Handle to the container window (widget).
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9453 * column: Zero based column.
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9454 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9455 int API dw_filesystem_get_column_type(HWND handle, int column)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9456 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9457 return dw_container_get_column_type( handle, column + 1 );
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9458 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9459
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9460 /*
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9461 * Sets the alternating row colors for container window (widget) handle.
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9462 * Parameters:
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9463 * handle: The window (widget) handle.
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9464 * oddcolor: Odd row background color in DW_RGB format or a default color index.
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9465 * evencolor: Even row background color in DW_RGB format or a default color index.
1211
70dca53cb071 Updated GTK3 with the behavior change just commited for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1208
diff changeset
9466 * DW_RGB_TRANSPARENT will disable coloring rows.
70dca53cb071 Updated GTK3 with the behavior change just commited for Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1208
diff changeset
9467 * DW_CLR_DEFAULT will use the system default alternating row colors.
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9468 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9469 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor)
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9470 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9471 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
1292
5ad8cf855c13 Fix for encoding a COLORREF incorrectly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
9472 unsigned long temp = _internal_color(oddcolor);
5ad8cf855c13 Fix for encoding a COLORREF incorrectly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1291
diff changeset
9473 COLORREF even, odd = RGB(DW_RED_VALUE(temp), DW_GREEN_VALUE(temp), DW_BLUE_VALUE(temp));
1293
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9474 temp = _internal_color(evencolor);
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9475 even = RGB(DW_RED_VALUE(temp), DW_GREEN_VALUE(temp), DW_BLUE_VALUE(temp));
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9476
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9477 /* Drop out on error */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9478 if(!cinfo)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9479 return;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9480
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9481 /* Create new brushes or remove if transparent */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9482 if(oddcolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9483 cinfo->odd = (oddcolor == DW_CLR_DEFAULT ? RGB(230, 230, 230) : odd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9484 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9485 cinfo->odd = oddcolor;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9486
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9487 if(evencolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9488 cinfo->even = (evencolor == DW_CLR_DEFAULT ? DW_RGB_TRANSPARENT : even);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9489 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9490 cinfo->even = evencolor;
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9491 }
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9492
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9493 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9494 * Sets the width of a column in the container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9495 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9496 * handle: Handle to window (widget) of container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9497 * column: Zero based column of width being set.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9498 * width: Width of column in pixels.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9499 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9500 void API dw_container_set_column_width(HWND handle, int column, int width)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9501 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9502 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9503 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9504
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9505 /* Internal version that handles both types */
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9506 void _dw_container_set_row_title(HWND handle, void *pointer, int row, char *title)
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9507 {
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9508 LV_ITEM lvi;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9509 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9510
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9511 if(pointer)
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9512 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9513 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9514 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9515
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9516 lvi.iItem = row + item;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9517 lvi.iSubItem = 0;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9518 lvi.mask = LVIF_PARAM;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9519 lvi.lParam = (LPARAM)title;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9520
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9521 if(!ListView_SetItem(handle, &lvi) && lvi.lParam)
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9522 lvi.lParam = 0;
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9523
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9524 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9525
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9526 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9527 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9528 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9529 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9530 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9531 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9532 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9533 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9534 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9535 _dw_container_set_row_title(pointer, pointer, row, title);
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9536 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9537
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9538 /*
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9539 * Changes the title of a row already inserted in the container.
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9540 * Parameters:
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9541 * handle: Handle to the container window (widget).
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9542 * row: Zero based row of data being set.
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9543 * title: String title of the item.
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9544 */
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9545 void API dw_container_change_row_title(HWND handle, int row, char *title)
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9546 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9547 _dw_container_set_row_title(handle, NULL, row, title);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9549
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9557 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9559 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9564 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 * handle: Handle to the window (widget) to be cleared.
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
9566 * redraw: TRUE to cause the container to redraw immediately.
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
9567 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9568 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9570 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9571 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9573 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9574 * Removes the first x rows from a container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9575 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9576 * handle: Handle to the window (widget) to be deleted from.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9577 * rowcount: The number of rows to be deleted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9578 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9579 void API dw_container_delete(HWND handle, int rowcount)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9580 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9581 int z, _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9582
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9583 for(z=0;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9584 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9585 ListView_DeleteItem(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9586 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9587 if(rowcount > _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9588 dw_window_set_data(handle, "_dw_index", 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9589 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9590 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER((_index - rowcount)));
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9591 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9592
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9593 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9594 * Scrolls container up or down.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9595 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9596 * handle: Handle to the window (widget) to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9597 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9598 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9599 * rows: The number of rows to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9600 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9601 void API dw_container_scroll(HWND handle, int direction, long rows)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9602 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9603 switch(direction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9604 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9605 case DW_SCROLL_TOP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9606 ListView_Scroll(handle, 0, -10000000);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9607 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9608 case DW_SCROLL_BOTTOM:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9609 ListView_Scroll(handle, 0, 10000000);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9610 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9611 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9612 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9613
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9614 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9617 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9618 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9619 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9620 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9621 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9622 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9623 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9624 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9625 int _index = ListView_GetNextItem(handle, -1, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9626
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9627 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9628 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9629
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9630 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9631
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9632 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9633 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9634
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9635 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9636
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9637 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9638 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9647 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9649 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9650 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9651 LV_ITEM lvi;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9652 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9654 _index = ListView_GetNextItem(handle, _index, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9655
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9656 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9657 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9658
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9659 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9660
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9661 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9662 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9663
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9664 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9665
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9666 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9667 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9668 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9669
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9670 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9671 * Cursors the item with the text speficied, and scrolls to that item.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9672 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9673 * handle: Handle to the window (widget) to be queried.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9674 * text: Text usually returned by dw_container_query().
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9675 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9676 void API dw_container_cursor(HWND handle, char *text)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9677 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9678 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
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: 1314
diff changeset
9679 int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9680
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9681 while ( index != -1 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9682 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9683 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9684
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9685 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9686
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9687 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9688 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9689
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9690 ListView_GetItem( handle, &lvi );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9691
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: 1314
diff changeset
9692 if ( (textcomp && lvi.lParam && strcmp( (char *)lvi.lParam, text ) == 0) || (!textcomp && (char *)lvi.lParam == text) )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9693 {
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
9694 unsigned long width, height;
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
9695
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9696 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED );
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
9697 dw_window_get_pos_size( handle, NULL, NULL, &width, &height);
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
9698 if(width < 10 || height < 10)
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
9699 dw_window_set_data( handle, "_dw_cursor", DW_INT_TO_POINTER(index) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9700 ListView_EnsureVisible( handle, index, TRUE );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9701 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9702 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9703
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9704 index = ListView_GetNextItem( handle, index, LVNI_ALL );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9705 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9706 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9707
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9708 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9709 * Deletes the item with the text speficied.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9710 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9711 * handle: Handle to the window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9712 * text: Text usually returned by dw_container_query().
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9713 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9714 void API dw_container_delete_row(HWND handle, char *text)
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9715 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9716 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
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: 1314
diff changeset
9717 int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9718
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9719 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9720 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9721 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9722
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9723 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9724
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9725 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9726 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9727
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9728 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9729
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: 1314
diff changeset
9730 if ( (textcomp && lvi.lParam && strcmp( (char *)lvi.lParam, text ) == 0) || (!textcomp && (char *)lvi.lParam == text) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9731 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9732 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9733
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9734 if(index < _index)
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9735 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER((_index - 1)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9736
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9737 ListView_DeleteItem(handle, index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9738 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9739 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9740
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9741 index = ListView_GetNextItem(handle, index, LVNI_ALL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9742 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9743 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9744
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9745 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9746 * Optimizes the column widths so that all data is visible.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9747 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9748 * handle: Handle to the window (widget) to be optimized.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9749 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9750 void API dw_container_optimize(HWND handle)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9751 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9752 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9753 if(cinfo && cinfo->columns == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9754 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9755 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9756 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9757 else if(cinfo && cinfo->columns > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9758 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9759 ULONG *flags = cinfo->flags, *columns = calloc(sizeof(ULONG), cinfo->columns);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9760 TCHAR *text = calloc(sizeof(TCHAR), 1024);
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9761 unsigned int z;
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9762 int index;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9763
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9764 /* Initialize with sizes of column labels */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9765 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9766 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9767 if(flags[z] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9768 columns[z] = 5;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9769 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9770 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9771 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9772
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9773 lvc.mask = LVCF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9774 lvc.cchTextMax = 1023;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9775 lvc.pszText = text;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9776
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9777 if(ListView_GetColumn(handle, z, &lvc))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9778 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9779
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9780 if(flags[z] & DW_CFA_RESERVED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9781 columns[z] += 20;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9782 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9783 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9784
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9785 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9786
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9787 /* Query all the item texts */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9788 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9789 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9790 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9791 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9792 unsigned int width;
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9793
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9794 ListView_GetItemText(handle, index, z, text, 1023);
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9795 width = ListView_GetStringWidth(handle, text);
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9796
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9797 /* Figure extra space for the icon for the first column */
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9798 if(z == 0)
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9799 width += 20;
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9800
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9801 if(width > columns[z])
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9802 columns[z] = width;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9803 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9804
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9805 index = ListView_GetNextItem(handle, index, LVNI_ALL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9806 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9807
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9808 /* Set the new sizes... Microsoft says we need to add
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9809 * padding to the calculated sized but does not give
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9810 * a value. Trial and error shows that 16 works for us.
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9811 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9812 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9813 ListView_SetColumnWidth(handle, z, columns[z] + 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9814
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9815 free(columns);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9816 free(text);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9817 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9818 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9819
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9820 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9821 * Inserts an icon into the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9822 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9823 * handle: Window handle that will handle taskbar icon messages.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9824 * icon: Icon handle to display in the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9825 * bubbletext: Text to show when the mouse is above the icon.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9826 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9827 void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext)
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9828 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9829 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9830
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9831 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9832 tnid.hWnd = handle;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9833 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9834 tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9835 tnid.uCallbackMessage = WM_USER+2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9836 tnid.hIcon = (HICON)icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9837 if(bubbletext)
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9838 _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9839 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9840 tnid.szTip[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9842 Shell_NotifyIcon(NIM_ADD, &tnid);
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9843 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9844
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9845 /*
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9846 * Deletes an icon from the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9847 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9848 * handle: Window handle that was used with dw_taskbar_insert().
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9849 * icon: Icon handle that was used with dw_taskbar_insert().
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9850 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9851 void API dw_taskbar_delete(HWND handle, HICN icon)
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9852 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9853 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9854
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9855 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9856 tnid.hWnd = handle;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9857 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9858
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9859 Shell_NotifyIcon(NIM_DELETE, &tnid);
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9860 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9861
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9862 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9863 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9865 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9867 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9868 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9869 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9870 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9871 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9872 HWND tmp = CreateWindow(ObjectClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
9873 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9874 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
9875 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9876 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9877 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9878 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9879 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9880 newbox->pad = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9881 newbox->type = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9882 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9883 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9884 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9885 newbox->cinfo.fore = newbox->cinfo.back = -1;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
9886 SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)newbox );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9887 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9892 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9894 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9896 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9897 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9898 HPEN hPen = TlsGetValue(_hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9899 HBRUSH hBrush = TlsGetValue(_hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9900 COLORREF foreground;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9901 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9902 GpBrush *brush = TlsGetValue(_gpBrush);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9903 GpPen *pen = TlsGetValue(_gpPen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9904 ARGB gpfore;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9905 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9906
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9907 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9908 foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9909 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9910 gpfore = MAKEARGB(255, DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9911
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9912 GdipDeletePen(pen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9913 GdipCreatePen1(gpfore, 1.0, UnitPixel, &pen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9914 TlsSetValue(_gpPen, (LPVOID)pen);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9915 GdipSetSolidFillColor(brush, gpfore);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9916 #endif
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
9917
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9918 DeleteObject(hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9919 DeleteObject(hBrush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9920 TlsSetValue(_foreground, (LPVOID)(uintptr_t)foreground);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9921 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9922 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9929 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9931 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9933 COLORREF background;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9934
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9935 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9936 background = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9937
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9938 if(value == DW_RGB_TRANSPARENT)
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9939 TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9940 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9941 TlsSetValue(_background, (LPVOID)(uintptr_t)background);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9942 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9944 /* Allows the user to choose a color using the system's color chooser dialog.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9945 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9946 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9947 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9948 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9949 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9950 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9951 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9952 CHOOSECOLOR cc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9953 unsigned long newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9954 COLORREF acrCustClr[16] = {0};
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9955
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9956 value = _internal_color(value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9957 if(value == DW_RGB_TRANSPARENT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9958 newcolor = DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9959 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9960 newcolor = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9961 ZeroMemory(&cc, sizeof(CHOOSECOLOR));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9962 cc.lStructSize = sizeof(CHOOSECOLOR);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9963 cc.rgbResult = newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9964 cc.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9965 cc.lpCustColors = (LPDWORD)acrCustClr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9966 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9967 if (ChooseColor(&cc) == TRUE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9968 newcolor = DW_RGB(DW_RED_VALUE(cc.rgbResult), DW_GREEN_VALUE(cc.rgbResult), DW_BLUE_VALUE(cc.rgbResult));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9969 return newcolor;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9970 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9971
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9975 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9977 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9978 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9979 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9980 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9981 #ifdef GDIPLUS
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9982 /* There doesn't seem to be an equivalent to SetPixel in GDI+ ...
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9983 * so instead we call dw_draw_rect() with 1 for width and height.
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9984 */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9985 dw_draw_rect(handle, pixmap, DW_DRAW_FILL | DW_DRAW_NOAA, x, y, 1, 1);
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9986 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9987 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9988
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9989 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9990 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9991 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9992 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9993 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9994 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9995
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9996 SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9997 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9998 ReleaseDC(handle, hdcPaint);
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9999 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10007 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10008 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10009 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10010 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10011 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10012 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10013 #ifdef GDIPLUS
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10014 GpGraphics *graphics = NULL;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10015 GpPen *pen = TlsGetValue(_gpPen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10016
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10017 if(handle)
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10018 GdipCreateFromHWND(handle, &graphics);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10019 else if(pixmap)
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10020 GdipCreateFromHDC(pixmap->hdc, &graphics);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10021 else
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10022 return;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10023
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10024 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10025 GdipDrawLineI(graphics, pen, x1, y1, x2, y2);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10026 GdipDeleteGraphics(graphics);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10027 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10028 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10029 HPEN oldPen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10030
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10031 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10032 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10033 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10034 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10035 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10036 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10037
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10038 oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10039 MoveToEx(hdcPaint, x1, y1, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10040 LineTo(hdcPaint, x2, y2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10041 SelectObject(hdcPaint, oldPen);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10042 /* For some reason Win98 (at least) fails
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10043 * to draw the last pixel. So I do it myself.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10044 */
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10045 SetPixel(hdcPaint, x2, y2, (COLORREF)TlsGetValue(_foreground));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10046 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10047 ReleaseDC(handle, hdcPaint);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10048 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10049 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10050
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10051 /* Internal function to generate POINT arrays used by Windows APIs */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10052 POINT *_makePoints(int *npoints, int *x, int *y)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10053 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10054 POINT *points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10055 int i;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10056
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10057 /*
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10058 * Allocate enough space for the number of points supplied plus 1.
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10059 * Under windows, unless the first and last points are the same
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10060 * the polygon won't be closed
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10061 */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10062 points = (POINT *)malloc( ((*npoints)+1) * sizeof(POINT) );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10063
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10064 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10065 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10066 for ( i = 0 ; i < *npoints ; i++ )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10067 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10068 points[i].x = x[i];
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10069 points[i].y = y[i];
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10070 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10071 if ( !( points[0].x == points[(*npoints)-1].x
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10072 && points[0].y == points[(*npoints)-1].y ) )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10073 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10074 /* set the last point to be the same as the first point... */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10075 points[*npoints].x = points[0].x;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10076 points[*npoints].y = points[0].y;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10077 /* ... and increment the number of points */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10078 (*npoints)++;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10079 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10080 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10081 return points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10082 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10083
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10084 /* Draw a closed polygon on a window (preferably a render window).
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10085 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10086 * handle: Handle to the window.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10087 * 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: 1270
diff changeset
10088 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10089 * number of points
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10090 * x[]: X coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10091 * y[]: Y coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10092 */
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: 1270
diff changeset
10093 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10094 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
10095 POINT *points = NULL;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10096
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10097 /* Sanity check */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10098 if(npoints < 1)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10099 return;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10100
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10101 #ifdef GDIPLUS
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10102 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10103 GpGraphics *graphics = NULL;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10104
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10105 if(handle)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10106 GdipCreateFromHWND(handle, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10107 else if(pixmap)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10108 GdipCreateFromHDC(pixmap->hdc, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10109 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10110 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10111
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10112 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10113 if(!(flags & DW_DRAW_NOAA))
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10114 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10115
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10116 if((points = _makePoints(&npoints, x, y)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10117 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10118 if(flags & DW_DRAW_FILL)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10119 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10120 GpBrush *brush = TlsGetValue(_gpBrush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10121
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10122 GdipFillPolygon2I(graphics, brush, points, npoints);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10123 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10124 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10125 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10126 GpPen *pen = TlsGetValue(_gpPen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10127
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10128 GdipDrawPolygonI(graphics, pen, points, npoints);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10129 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10130 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10131 GdipDeleteGraphics(graphics);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10132 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10133 #else
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10134 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10135 HDC hdcPaint;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10136
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10137 if ( handle )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10138 hdcPaint = GetDC( handle );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10139 else if ( pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10140 hdcPaint = pixmap->hdc;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10141 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10142 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10143
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10144 if((points = _makePoints(&npoints, x, y)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10145 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10146 HBRUSH oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10147 HPEN oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10148
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10149 if ( flags & DW_DRAW_FILL )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10150 Polygon( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10151 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10152 Polyline( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10153
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10154 SelectObject( hdcPaint, oldBrush );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10155 SelectObject( hdcPaint, oldPen );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10156 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10157
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10158 if ( !pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10159 ReleaseDC( handle, hdcPaint );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10160 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10161 #endif
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10162 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10163 free(points);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10164 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10165
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10166 /* Draw a rectangle on a window (preferably a render window).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10167 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10168 * handle: Handle to the window.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10169 * 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: 1270
diff changeset
10170 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10171 * x: X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10172 * y: Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10173 * width: Width of rectangle.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10174 * height: Height of rectangle.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10175 */
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: 1270
diff changeset
10176 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10177 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10178 #ifdef GDIPLUS
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10179 GpGraphics *graphics = NULL;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10180
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10181 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10182 GdipCreateFromHWND(handle, &graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10183 else if(pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10184 GdipCreateFromHDC(pixmap->hdc, &graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10185 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10186 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10187
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10188 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10189 if(!(flags & DW_DRAW_NOAA))
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10190 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10191
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10192 if(flags & DW_DRAW_FILL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10193 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10194 GpBrush *brush = TlsGetValue(_gpBrush);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10195
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10196 GdipFillRectangleI(graphics, brush, x, y, width, height);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10197 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10198 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10199 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10200 GpPen *pen = TlsGetValue(_gpPen);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10201
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10202 GdipDrawRectangleI(graphics, pen, x, y, width, height);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10203 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10204 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10205 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10206 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10207 RECT Rect;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10208
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10209 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10210 hdcPaint = GetDC(handle);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10211 else if(pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10212 hdcPaint = pixmap->hdc;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10213 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10214 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10215
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10216 SetRect(&Rect, x, y, x + width , y + height );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10217 if(flags & DW_DRAW_FILL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10218 FillRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10219 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10220 FrameRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10221 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10222 ReleaseDC(handle, hdcPaint);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10223 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10224 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10225
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10226 /* 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: 1257
diff changeset
10227 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10228 * handle: Handle to the window.
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10229 * 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: 1270
diff changeset
10230 * 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: 1270
diff changeset
10231 * 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: 1257
diff changeset
10232 * 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: 1257
diff changeset
10233 * 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: 1257
diff changeset
10234 * 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: 1257
diff changeset
10235 * 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: 1257
diff changeset
10236 * 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: 1257
diff changeset
10237 * 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: 1257
diff changeset
10238 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10239 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: 1257
diff changeset
10240 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10241 #ifdef GDIPLUS
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10242 GpGraphics *graphics = NULL;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10243 GpPen *pen = TlsGetValue(_gpPen);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10244
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10245 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10246 GdipCreateFromHWND(handle, &graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10247 else if(pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10248 GdipCreateFromHDC(pixmap->hdc, &graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10249 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10250 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10251
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10252 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10253 if(!(flags & DW_DRAW_NOAA))
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10254 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10255
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10256 if(flags & DW_DRAW_FULL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10257 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10258 if(flags & DW_DRAW_FILL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10259 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10260 GpBrush *brush = TlsGetValue(_gpBrush);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10261
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10262 GdipFillEllipseI(graphics, brush, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10263 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10264 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10265 GdipDrawEllipseI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10266 }
1270
24f1dc19601d Implemented DW_DRAW_FULL on Windows and implemented DW_DRAW_FILL for ellipses.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1268
diff changeset
10267 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10268 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10269 double a1 = atan2((y1-yorigin), (x1-xorigin));
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10270 double a2 = atan2((y2-yorigin), (x2-xorigin));
1632
fdf874f25076 Fixed full arcs with GDI+ and disabled antialiased rendering for rectangles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1631
diff changeset
10271 double dx = xorigin - x1;
fdf874f25076 Fixed full arcs with GDI+ and disabled antialiased rendering for rectangles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1631
diff changeset
10272 double dy = yorigin - y1;
fdf874f25076 Fixed full arcs with GDI+ and disabled antialiased rendering for rectangles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1631
diff changeset
10273 double r = sqrt(dx*dx + dy*dy);
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10274 double sweep;
1632
fdf874f25076 Fixed full arcs with GDI+ and disabled antialiased rendering for rectangles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1631
diff changeset
10275 int ri = (int)r;
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10276
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10277 /* Convert to degrees */
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10278 a1 *= (180.0 / M_PI);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10279 a2 *= (180.0 / M_PI);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10280 sweep = fabs(a1 - a2);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10281
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10282 GdipDrawArcI(graphics, pen, xorigin-ri, yorigin-ri, ri*2, ri*2, (REAL)a1, (REAL)sweep);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10283 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10284 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10285 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10286 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10287 HBRUSH oldBrush;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10288 HPEN oldPen;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10289 double dx = xorigin - x1;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10290 double dy = yorigin - y1;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10291 double r = sqrt(dx*dx + dy*dy);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10292 int ri = (int)r;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10293
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10294 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10295 hdcPaint = GetDC(handle);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10296 else if(pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10297 hdcPaint = pixmap->hdc;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10298 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10299 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10300
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10301 if(flags & DW_DRAW_FILL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10302 oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10303 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10304 oldBrush = SelectObject( hdcPaint, GetStockObject(HOLLOW_BRUSH) );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10305 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10306 if(flags & DW_DRAW_FULL)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10307 Ellipse(hdcPaint, x1, y1, x2, y2);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10308 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10309 Arc(hdcPaint, xorigin-ri, yorigin-ri, xorigin+ri, yorigin+ri, x2, y2, x1, y1);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10310 SelectObject( hdcPaint, oldBrush );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10311 SelectObject( hdcPaint, oldPen );
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10312
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10313 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10314 ReleaseDC(handle, hdcPaint);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10315 #endif
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10316 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10317
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10318 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10319 /* Internal function to increase or decrease coordinates/sizes
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10320 * by the difference of the screen DPI (96) and the context DPI.
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10321 */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10322 void _convert_dpi(HDC hdc, int *x, int *y, int mult)
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10323 {
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10324 int ratiox = (int)GetDeviceCaps(hdc, LOGPIXELSX)/96;
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10325 int ratioy = (int)GetDeviceCaps(hdc, LOGPIXELSY)/96;
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10326 if(ratiox > 1 && ratioy > 1)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10327 {
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10328 if(mult)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10329 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10330 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10331 *x *= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10332 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10333 *y *= ratioy;
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10334 }
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10335 else
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10336 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10337 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10338 *x /= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10339 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10340 *y /= ratioy;
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10341 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10342 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10343 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10344 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10345
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10350 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10351 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10352 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10353 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10354 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10355 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10356 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10357 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10358 HFONT hFont = 0, oldFont = 0;
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: 1143
diff changeset
10359 ColorInfo *cinfo = NULL;
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10360 COLORREF background;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10361 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10362
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10363 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10364 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10365 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10366 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10367 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10368 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10369
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10370 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10371 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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: 1143
diff changeset
10372 else if(pixmap->font)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10373 hFont = pixmap->font;
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10374 else if(pixmap->handle)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10375 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10376
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10377 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10378 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10379 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10380 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10381 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10382
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10383 background = (COLORREF)(uintptr_t)TlsGetValue(_background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10384 if(hFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10385 oldFont = SelectObject(hdc, hFont);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10386 SetTextColor(hdc, (COLORREF)(uintptr_t)TlsGetValue(_foreground));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10387 if(background == DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10388 SetBkMode(hdc, TRANSPARENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10389 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10390 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10391 SetBkMode(hdc, OPAQUE);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10392 SetBkColor(hdc, background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10393 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10394 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10395 _convert_dpi(hdc, &x, &y, TRUE);
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10396 #endif
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10397 TextOut(hdc, x, y, wtext, (int)_tcslen(wtext));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10398 if(oldFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10399 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10400 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10401 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10402 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10403 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10405
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10406 /* Query the width and height of a text string.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10407 * Parameters:
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10408 * handle: Handle to the window.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10409 * pixmap: Handle to the pixmap. (choose only one of these)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10410 * text: Text to be queried.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10411 * width: Pointer to a variable to be filled in with the width.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10412 * height Pointer to a variable to be filled in with the height.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10413 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
10414 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10415 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10416 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10417 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10418 HFONT hFont = NULL, oldFont;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10419 SIZE sz;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10420 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10421
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10422 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10423 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10424 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10425 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10426 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10427 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10428
1231
4a7a9f102a5f Fix for dw_font_text_extents_get() not on Windows honoring the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1229
diff changeset
10429 if(pixmap && pixmap->font)
4a7a9f102a5f Fix for dw_font_text_extents_get() not on Windows honoring the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1229
diff changeset
10430 {
4a7a9f102a5f Fix for dw_font_text_extents_get() not on Windows honoring the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1229
diff changeset
10431 hFont = pixmap->font;
4a7a9f102a5f Fix for dw_font_text_extents_get() not on Windows honoring the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1229
diff changeset
10432 }
4a7a9f102a5f Fix for dw_font_text_extents_get() not on Windows honoring the font set with dw_pixmap_set_font().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1229
diff changeset
10433 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10434 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10435 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10436
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10437 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10438 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10439 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10440 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10441
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10442 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10443 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10444 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10445 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10446 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10447 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10448 oldFont = SelectObject(hdc, hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10449
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10450 GetTextExtentPoint32(hdc, wtext, (int)_tcslen(wtext), &sz);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10451
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10452 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10453 *width = sz.cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10454
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10455 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10456 *height = sz.cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10457
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10458 #ifdef GDIPLUS
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10459 _convert_dpi(hdc, width, height, FALSE);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10460 #endif
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10461
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10462 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10463 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10464 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10465 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10466 ReleaseDC(handle, hdc);
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10467 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
10468
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10470 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10472 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10473 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10476 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10477 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10478 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10479 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10480 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10481 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10482 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10483 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10484 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10485 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10486 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10487 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10488 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10489 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10490
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10491 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10492 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10493
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10494 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10495
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10496 pixmap->width = width; pixmap->height = height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10497
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10498 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10499 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10500 pixmap->hdc = CreateCompatibleDC(hdc);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10501 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10502
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10503 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10504
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10505 ReleaseDC(handle, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10506
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10507 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10509
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10510 #ifndef GDIPLUS
966
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10511 /* Read the file bitmap header ourselves...
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10512 * apparently we can't check the depth once loaded...
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10513 * since it seems to normalize it to our screen depth.
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10514 */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10515 unsigned long _read_bitmap_header(char *file)
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10516 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10517 BITMAPFILEHEADER header;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10518 BITMAPINFO *info;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10519 FILE *fp;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10520 int infosize;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10521 int depth = 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10522
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10523 /* Try opening the file; use "rb" mode to read this *binary* file. */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10524 if((fp = fopen(file, "rb")) == NULL)
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10525 return 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10526
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10527 /* Read the file header and any following bitmap information... */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10528 if(fread(&header, sizeof(BITMAPFILEHEADER), 1, fp) < 1)
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10529 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10530 /* Couldn't read the file header */
967
c8490b0d8577 Minor formatting fix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 966
diff changeset
10531 fclose(fp);
966
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10532 return 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10533 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10534
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10535 if(header.bfType != 'MB') /* Check for BM reversed... */
966
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10536 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10537 /* Not a bitmap file */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10538 fclose(fp);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10539 return 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10540 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10541
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10542 infosize = header.bfOffBits - sizeof(BITMAPFILEHEADER);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10543 if((info = (BITMAPINFO *)calloc(infosize, 1)) == NULL)
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10544 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10545 /* Couldn't allocate memory for bitmap info */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10546 fclose(fp);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10547 return 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10548 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10549
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10550 if(fread(info, 1, infosize, fp) == infosize)
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10551 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10552 /* Read the bitmap header */
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10553 depth = info->bmiHeader.biBitCount;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10554 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10555 free(info);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10556 fclose(fp);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10557 return depth;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10558 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10559 #endif
966
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10560
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10561 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10562 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10563 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10564 * handle: Window handle the pixmap is associated with.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10565 * filename: Name of the file, omit extention to have
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10566 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10567 * (BMP on OS/2 or Windows, XPM on Unix)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10568 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10569 * A handle to a pixmap or NULL on failure.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10570 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10571 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10572 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10573 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10574 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10575 HDC hdc;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10576 #ifndef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10577 char *file;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10578 #endif
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10579
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10580 if (!filename || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10581 return NULL;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10582
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10583 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10584 pixmap->hbm = _dw_load_bitmap(filename, &pixmap->depth);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10585 #else
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10586 file = _alloca(strlen(filename) + 5);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10587 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10588
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10589 /* check if we can read from this file (it exists and read permission) */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10590 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10591 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10592 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10593 strcat(file, ".bmp");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10594 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10595 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10596 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10597 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10598 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10599 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10600 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10601
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10602 pixmap->hbm = (HBITMAP)LoadImage(NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10603 pixmap->depth = _read_bitmap_header(file);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10604 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10605
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10606 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10607
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10608 if ( !pixmap->hbm )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10609 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10610 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10611 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10612 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10613
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10614 hdc = GetDC(handle);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10615
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10616 pixmap->hdc = CreateCompatibleDC( hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10617 GetObject( pixmap->hbm, sizeof(bm), &bm );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10618 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10619 SelectObject( pixmap->hdc, pixmap->hbm );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10620 ReleaseDC( handle, hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10621 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10622
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10623 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10624 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10625
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10626 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10627 * Creates a pixmap from memory.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10628 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10629 * handle: Window handle the pixmap is associated with.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10630 * data: Source of the image data
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10631 * (BMP on OS/2 or Windows, XPM on Unix)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10632 * le: length of data
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10633 * Returns:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10634 * A handle to a pixmap or NULL on failure.
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10635 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10636 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len)
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10637 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10638 HPIXMAP pixmap;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10639 BITMAP bm;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10640 HDC hdc;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10641 char *file;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10642 FILE *fp;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10643
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10644 if ( !(pixmap = calloc(1,sizeof(struct _hpixmap))) )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10645 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10646 return NULL;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10647 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10648
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10649 hdc = GetDC(handle);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10650
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10651 pixmap->handle = handle;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10652
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10653 file = _tempnam( _dw_alternate_temp_dir, "dw" );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10654 if ( file != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10655 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10656 fp = fopen( file, "wb" );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10657 if ( fp != NULL )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10658 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10659 fwrite( data, 1, len, fp );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10660 fclose( fp );
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10661 #ifdef GDIPLUS
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
10662 pixmap->hbm = _dw_load_bitmap(file, NULL);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10663 #else
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10664 pixmap->hbm = (HBITMAP)LoadImage( NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
966
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10665 pixmap->depth = _read_bitmap_header(file);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10666 #endif
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10667 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10668 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10669 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
10670 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10671 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10672 free( pixmap );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10673 return NULL;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10674 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
10675 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10676 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10677 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10678
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10679 if ( !pixmap->hbm )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10680 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10681 free( pixmap );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10682 ReleaseDC( handle, hdc );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10683 return NULL;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10684 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10685
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10686 pixmap->hdc = CreateCompatibleDC( hdc );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10687
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10688 GetObject( pixmap->hbm, sizeof(bm), &bm );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10689
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10690 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10691
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10692 SelectObject( pixmap->hdc, pixmap->hbm );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10693
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10694 ReleaseDC( handle, hdc );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10695 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10696
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10697 return pixmap;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10698 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10699
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10700 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10701 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10702 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10703 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10704 {
1006
3e1c70896c13 Switched to using TransparentBlt() on Windows, and allow transparent bitblt for any depths below 32bpp.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 999
diff changeset
10705 if ( pixmap && pixmap->depth < 32)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10706 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10707 pixmap->transcolor = _internal_color(color);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10708 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10709 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10710
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10711 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10717 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10719 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10720 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10721 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10722 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10723 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10724
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10725 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10726 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10727
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10728 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10729
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10730 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10731 pixmap->hdc = CreateCompatibleDC(hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10732
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10733 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10734
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10735 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10736 pixmap->depth = bm.bmBitsPixel;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10737
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10738 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10739
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10740 ReleaseDC(handle, hdc);
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10741 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10742
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10743 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10745
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10746 /*
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: 1143
diff changeset
10747 * Sets the font used by a specified pixmap.
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10748 * Normally the pixmap font is obtained from the associated window handle.
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10749 * However this can be used to override that, or for pixmaps with no window.
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10750 * Parameters:
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10751 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10752 * passed to the application via a callback.
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10753 * fontname: Name and size of the font in the form "size.fontname"
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10754 * 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: 1143
diff changeset
10755 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10756 */
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10757 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10758 {
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10759 if(pixmap)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10760 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
10761 HFONT hfont = _acquire_font2(pixmap->hdc, 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: 1143
diff changeset
10762
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10763 if(hfont)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10764 {
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10765 HFONT oldfont = pixmap->font;
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10766 pixmap->font = hfont;
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10767 if(oldfont)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10768 DeleteObject(oldfont);
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10769 return DW_ERROR_NONE;
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10770 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10771 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10772 return DW_ERROR_GENERAL;
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10773 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10774
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10775 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10777 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10779 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10780 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10781 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10782 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10783 if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10784 {
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: 1143
diff changeset
10785 DeleteDC(pixmap->hdc);
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10786 DeleteObject(pixmap->hbm);
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10787 if(pixmap->font)
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10788 DeleteObject(pixmap->font);
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10789 free(pixmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10790 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10795 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10803 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10805 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10806 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10807 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)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10808 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10809 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10810 }
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10811
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10812 /*
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10813 * Copies from one surface to another allowing for stretching.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10814 * Parameters:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10815 * dest: Destination window handle.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10816 * destp: Destination pixmap. (choose only one).
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10817 * xdest: X coordinate of destination.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10818 * ydest: Y coordinate of destination.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10819 * width: Width of the target area.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10820 * height: Height of the target area.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10821 * src: Source window handle.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10822 * srcp: Source pixmap. (choose only one).
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10823 * xsrc: X coordinate of source.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10824 * ysrc: Y coordinate of source.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10825 * srcwidth: Width of area to copy.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10826 * srcheight: Height of area to copy.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10827 * Returns:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10828 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10829 */
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10830 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)
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10831 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10832 HDC hdcdest;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10833 HDC hdcsrc;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10834 static BLENDFUNCTION bf = { AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA };
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10835 int swidth = srcwidth, sheight = srcheight;
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10836
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10837 /* Do some sanity checks */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10838 if ( dest )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10839 hdcdest = GetDC( dest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10840 else if ( destp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10841 hdcdest = destp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10842 else
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10843 return DW_ERROR_GENERAL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10844
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10845 if ( src )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10846 hdcsrc = GetDC( src );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10847 else if ( srcp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10848 hdcsrc = srcp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10849 else
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10850 return DW_ERROR_GENERAL;
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10851
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10852 if((srcheight == -1 || srcwidth == -1) && srcheight != srcwidth)
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10853 return DW_ERROR_GENERAL;
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10854
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10855 if(srcheight == -1 && srcwidth == -1)
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10856 {
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10857 swidth = width;
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10858 sheight = height;
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10859 }
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10860
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10861 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10862 /* Do conversion on all the coordinates */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10863 _convert_dpi(hdcdest, &xdest, &ydest, TRUE);
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10864 _convert_dpi(hdcdest, &width, &height, TRUE);
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10865 _convert_dpi(hdcsrc, &xsrc, &ysrc, TRUE);
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10866 _convert_dpi(hdcsrc, &swidth, &sheight, TRUE);
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10867 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10868
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10869 /* If it is a 32bpp bitmap (with alpha) use AlphaBlend unless it fails */
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10870 if ( srcp && srcp->depth == 32 && AlphaBlend( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, swidth, sheight, bf ) )
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10871 {
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10872 /* Don't do anything */
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10873 }
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10874 /* Otherwise perform special bitblt with manual transparency */
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10875 else if ( srcp && srcp->transcolor != DW_RGB_TRANSPARENT )
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10876 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10877 TransparentBlt( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, swidth, sheight, RGB( DW_RED_VALUE(srcp->transcolor), DW_GREEN_VALUE(srcp->transcolor), DW_BLUE_VALUE(srcp->transcolor)) );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10878 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10879 else
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10880 {
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10881 /* Finally fall back to the classic BitBlt */
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10882 if( srcwidth == -1 && srcheight == -1)
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10883 BitBlt( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, SRCCOPY );
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10884 else
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10885 StretchBlt( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, swidth, sheight, SRCCOPY );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10886 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10887 if ( !destp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10888 ReleaseDC( dest, hdcdest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10889 if ( !srcp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10890 ReleaseDC( src, hdcsrc );
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10891
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10892 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10893 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10894
527
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10895 /* Run Beep() in a separate thread so it doesn't block */
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10896 void _beepthread(void *data)
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10897 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10898 int *info = (int *)data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10899
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10900 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10901 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10902 Beep(info[0], info[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10903 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10904 }
527
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10905 }
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10906
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10907 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10908 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10909 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10910 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10911 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10912 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10913 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10914 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10915 int *info = malloc(sizeof(int) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10916
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10917 if(info)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10918 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10919 info[0] = freq;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10920 info[1] = dur;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10921
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10922 _beginthread(_beepthread, 100, (void *)info);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10923 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10924 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10925
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10926 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10927 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10928 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10929 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10930 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10931 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10932 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10933 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10934 if(!handle)
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: 975
diff changeset
10935 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10936
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10937 *handle = LoadLibrary(UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10938 return (NULL == *handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10939 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10940
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10941 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10942 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10943 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10944 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10945 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10946 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10947 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10948 int API dw_module_symbol(HMOD handle, char *name, void**func)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10949 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10950 if(!func || !name)
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: 975
diff changeset
10951 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10952
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10953 if(0 == strlen(name))
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: 975
diff changeset
10954 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10955
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10956 *func = (void*)GetProcAddress(handle, name);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10957 return (NULL == *func);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10958 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10959
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10960 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10961 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10962 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10963 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10964 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10965 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10966 return FreeLibrary(handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10967 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10968
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10970 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10972 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10974 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10978 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10980 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10981 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10982 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10983 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10984 CloseHandle((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10987 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10988 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10989 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10990 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10991 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10992 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10993 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10994 if(_dwtid == dw_thread_id())
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10995 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10996 int rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10997
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10998 while(rc == WAIT_TIMEOUT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10999 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11000 dw_main_sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11001 rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11002 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11003 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
11004 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11005 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11008 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11009 * 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
11010 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11011 * 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
11012 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11013 * 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
11014 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11015 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
11016 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11017 if(WaitForSingleObject((HANDLE)mutex, 0) == WAIT_OBJECT_0)
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11018 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
11019 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
11020 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11021
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11022 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11023 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11025 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11027 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11029 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11031
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11033 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11035 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11037 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11041 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11043 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11044 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11045 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11046 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11047 if(ResetEvent(eve))
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11048 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: 1154
diff changeset
11049 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11050 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11051
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11052 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11053 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11054 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11056 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11057 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11058 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11059 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11060 if(SetEvent(eve))
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11061 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: 1154
diff changeset
11062 return DW_ERROR_GENERAL;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11063 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11066 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11067 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11068 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11069 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11070 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11071 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11072 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11073 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11074
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11075 rc = WaitForSingleObject(eve, timeout != -1 ? timeout : INFINITE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11076 if(rc == WAIT_OBJECT_0)
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: 975
diff changeset
11077 return DW_ERROR_NONE;
1154
052f01522c53 dw_event_wait() was returning DW_ERROR_TIMEOUT in the wrong state on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
11078 if(rc == WAIT_TIMEOUT)
052f01522c53 dw_event_wait() was returning DW_ERROR_TIMEOUT in the wrong state on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1152
diff changeset
11079 return DW_ERROR_TIMEOUT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11080 if(rc == WAIT_ABANDONED)
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11081 return DW_ERROR_INTERRUPT;
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: 975
diff changeset
11082 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11085 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11086 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11088 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11089 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11090 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11091 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11092 if(eve && CloseHandle(*eve))
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11093 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: 1154
diff changeset
11094 return DW_ERROR_GENERAL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11095 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11096
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11097 /* Create a named event semaphore which can be
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11098 * opened from other processes.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11099 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11100 * eve: Pointer to an event handle to receive handle.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11101 * name: Name given to semaphore which can be opened
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11102 * by other processes.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11103 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11104 HEV API dw_named_event_new(char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11105 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11106 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11107
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11108 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11109 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11110 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11111
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11112 return CreateEvent(&sa, TRUE, FALSE, UTF8toWide(name));
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11113 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11114
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11115 /* Destroy this semaphore.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11116 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11117 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11118 * a create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11119 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11120 HEV API dw_named_event_get(char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11121 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11122 return OpenEvent(EVENT_ALL_ACCESS, FALSE, UTF8toWide(name));
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11123 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11124
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11125 /* Resets the event semaphore so threads who call wait
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11126 * on this semaphore will block.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11127 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11128 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11129 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11130 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11131 int API dw_named_event_reset(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11132 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11133 if(ResetEvent(eve))
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11134 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: 1154
diff changeset
11135 return DW_ERROR_GENERAL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11136 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11137
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11138 /* Sets the posted state of an event semaphore, any threads
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11139 * waiting on the semaphore will no longer block.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11140 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11141 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11142 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11143 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11144 int API dw_named_event_post(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11145 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11146 if(SetEvent(eve))
1170
4b94c9f5ddeb Missing return on Windows... surprised this compiled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
11147 return DW_ERROR_NONE;
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11148 return DW_ERROR_GENERAL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11149 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11150
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11151 /* Waits on the specified semaphore until it becomes
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11152 * posted, or returns immediately if it already is posted.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11153 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11154 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11155 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11156 * timeout: Number of milliseconds before timing out
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11157 * or -1 if indefinite.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11158 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11159 int API dw_named_event_wait(HEV eve, unsigned long timeout)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11160 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11161 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11162
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11163 rc = WaitForSingleObject(eve, timeout != -1 ? timeout : INFINITE);
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11164 if(rc == WAIT_OBJECT_0)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11165 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: 1154
diff changeset
11166 if(rc == WAIT_TIMEOUT)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11167 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: 1154
diff changeset
11168 if(rc == WAIT_ABANDONED)
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11169 return DW_ERROR_INTERRUPT;
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11170 return DW_ERROR_GENERAL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11171 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11172
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11173 /* Release this semaphore, if there are no more open
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11174 * handles on this semaphore the semaphore will be destroyed.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11175 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11176 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11177 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11178 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11179 int API dw_named_event_close(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11180 {
1155
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11181 if(CloseHandle(eve))
e6a2f57c0842 Added support for infinite wait for dw_event_wait() on Mac, Unix and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1154
diff changeset
11182 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: 1154
diff changeset
11183 return DW_ERROR_GENERAL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11184 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11185
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11186 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11187 * Allocates a shared memory region with a name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11188 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11189 * handle: A pointer to receive a SHM identifier.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11190 * dest: A pointer to a pointer to receive the memory address.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11191 * size: Size in bytes of the shared memory region to allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11192 * name: A string pointer to a unique memory name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11193 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11194 HSHM API dw_named_memory_new(void **dest, int size, char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11195 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11196 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11197 HSHM handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11198
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11199 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11200 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11201 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11202
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11203 handle = CreateFileMapping((HANDLE)0xFFFFFFFF, &sa, PAGE_READWRITE, 0, size, UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11204
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11205 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11206 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11207
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11208 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11209
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11210 if(!*dest)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11211 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11212 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11213 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11214 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11215
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11216 return handle;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11217 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11218
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11219 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11220 * Aquires shared memory region with a name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11221 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11222 * dest: A pointer to a pointer to receive the memory address.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11223 * size: Size in bytes of the shared memory region to requested.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11224 * name: A string pointer to a unique memory name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11225 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11226 HSHM API dw_named_memory_get(void **dest, int size, char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11227 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11228 HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11229
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11230 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11231 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11233 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11234
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11235 if(!*dest)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11236 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11237 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11238 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11239 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11240
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11241 return handle;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11242 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11243
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11244 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11245 * Frees a shared memory region previously allocated.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11246 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11247 * handle: Handle obtained from DB_named_memory_allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11248 * ptr: The memory address aquired with DB_named_memory_allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11249 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11250 int API dw_named_memory_free(HSHM handle, void *ptr)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11251 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11252 UnmapViewOfFile(ptr);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11253 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11254 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11257 /*
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11258 * Encapsulate thread creation on Win32.
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11259 */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11260 void _dwthreadstart(void *data)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11261 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11262 void (* threadfunc)(void *) = NULL;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11263 void **tmp = (void **)data;
970
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11264 HPEN hPen;
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11265 HBRUSH hBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11266 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11267 GpBrush *brush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11268 GpPen *pen;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11269 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11270
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11271 _init_thread();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11272
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11273 threadfunc = (void (*)(void *))tmp[0];
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11274 threadfunc(tmp[1]);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11275
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11276 free(tmp);
970
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11277 if((hPen = TlsGetValue(_hPen)))
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11278 DeleteObject(hPen);
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11279 if((hBrush = TlsGetValue(_hBrush)))
b00943f21392 We need to destroy the thread's brush and pen when the thread exits so we don't leak objects on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 969
diff changeset
11280 DeleteObject(hBrush);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11281 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11282 if((brush = TlsGetValue(_gpBrush)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11283 GdipDeleteBrush(brush);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11284 if((pen = TlsGetValue(_gpPen)))
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11285 GdipDeletePen(pen);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
11286 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11287 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11288
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11289 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11290 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11291 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11292 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11293 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11294 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11295 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11296 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11297 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11298 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11299 return 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11300 #else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11301 void **tmp = malloc(sizeof(void *) * 2);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11302
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11303 tmp[0] = func;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11304 tmp[1] = data;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11305
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11306 return (DWTID)_beginthread((void(*)(void *))_dwthreadstart, stack, tmp);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11307 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11310 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11311 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11312 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11313 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11314 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11315 #if !defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11316 _endthread();
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11317 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11318 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11319
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11320 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11321 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11322 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11323 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11324 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11325 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11326 return 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11327 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11328 return (DWTID)GetCurrentThreadId();
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11329 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11332 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11333 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11334 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11335 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11336 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11337 void API dw_exit(int exitcode)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11338 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11339 OleUninitialize();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11340 #ifdef AEROGLASS
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11341 /* Free any in use libraries */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11342 FreeLibrary(hdwm);
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
11343 #endif
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
11344 FreeLibrary(huxtheme);
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
11345 DestroyWindow(hwndTooltip);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11346 exit(exitcode);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11349 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11350 * Creates a splitbar window (widget) with given parameters.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11351 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
11352 * type: Value can be DW_VERT or DW_HORZ.
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11353 * topleft: Handle to the window to be top or left.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11354 * bottomright: Handle to the window to be bottom or right.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11355 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11356 * A handle to a splitbar window or NULL on failure.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11357 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11358 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11359 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11360 HWND tmp = CreateWindow(SplitbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11361 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11362 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
11363 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11364 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11365 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11366 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11367 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11368
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11369 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11370 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11371 HWND tmpbox = dw_box_new(DW_VERT, 0);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11372 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11373
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11374 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11375 SetParent(tmpbox, tmp);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11376 dw_window_set_data(tmp, "_dw_topleft", DW_POINTER(tmpbox));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11377
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11378 tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11379 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11380 SetParent(tmpbox, tmp);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11381 dw_window_set_data(tmp, "_dw_bottomright", DW_POINTER(tmpbox));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11382 *percent = 50.0;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11383 dw_window_set_data(tmp, "_dw_percent", DW_POINTER(percent));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11384 dw_window_set_data(tmp, "_dw_type", DW_INT_TO_POINTER(type));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11385 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11386 return tmp;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11387 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11388
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11389 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11390 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11391 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11392 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11393 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11394 void API dw_splitbar_set(HWND handle, float percent)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11395 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11396 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11397 int type = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_type"));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11398 unsigned long width, height;
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
11399
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11400 if(mypercent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11401 *mypercent = percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11402
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11403 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11404
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: 1448
diff changeset
11405 if(width > 0 && height > 0)
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: 1448
diff changeset
11406 _handle_splitbar_resize(handle, percent, type, width, height);
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11407 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11408
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11409 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11410 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11411 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11412 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11413 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11414 float API dw_splitbar_get(HWND handle)
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
11415 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11416 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11417
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11418 if(percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11419 return *percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11420 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11421 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11422
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11423 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11424 * Creates a calendar window (widget) with given parameters.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11425 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11426 * type: Value can be DW_VERT or DW_HORZ.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11427 * topleft: Handle to the window to be top or left.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11428 * bottomright: Handle to the window to be bottom or right.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11429 * Classname: SysMonthCal32
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11430 * Returns:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11431 * A handle to a calendar window or NULL on failure.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11432 */
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11433 HWND API dw_calendar_new(unsigned long id)
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11434 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11435 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11436 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11437 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11438 MONTHCAL_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11439 NULL,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11440 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | MCS_DAYSTATE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
11441 0,0,0,0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11442 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11443 (HMENU)(uintptr_t)id,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11444 DWInstance,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11445 NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11446 if ( tmp )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11447 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11448 // Get the size required to show an entire month.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11449 MonthCal_GetMinReqRect(tmp, &rc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11450 // Resize the control now that the size values have been obtained.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11451 SetWindowPos(tmp, NULL, 0, 0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11452 rc.right, rc.bottom,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11453 SWP_NOZORDER | SWP_NOMOVE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11454 mds[0] = mds[1] = mds[2] = (MONTHDAYSTATE)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11455 MonthCal_SetDayState(tmp,3,mds);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11456 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11457 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11458 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11459 return NULL;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11460 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11461
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11462 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11463 * Sets the current date of a calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11464 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11465 * handle: The handle to the calendar returned by dw_calendar_new().
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11466 * year: The year to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11467 * month: The month to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11468 * day: The day to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11469 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11470 void API dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11471 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11472 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11473 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11474 date.wYear = year;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11475 date.wMonth = month;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11476 date.wDay = day;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11477 if ( MonthCal_SetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11478 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11479 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11480 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11481 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11482 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11483 mds[0] = mds[1] = mds[2] = (MONTHDAYSTATE)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11484 MonthCal_SetDayState(handle,3,mds);
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11485 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11486
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11487 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11488 * Gets the date from the calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11489 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11490 * handle: The handle to the calendar returned by dw_calendar_new().
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11491 * year: Pointer to the year to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11492 * month: Pointer to the month to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11493 * day: Pointer to the day to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11494 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11495 void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11496 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11497 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11498 if ( MonthCal_GetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11499 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11500 *year = date.wYear;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11501 *month = date.wMonth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11502 *day = date.wDay;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11503 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11504 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11505 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11506 *year = *month = *day = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11507 }
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11508 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11509
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11510 /* Internal function to set the focus from the window thread */
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11511 void _dw_set_focus(HWND handle)
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11512 {
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11513 SetFocus(handle);
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11514 }
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11515
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11516 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11517 * 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
11518 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11519 * 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
11520 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11521 * 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
11522 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11523 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
11524 {
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11525 if(_dwtid == (DWTID)-1)
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11526 SetFocus(handle);
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11527 else
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11528 dw_window_function(handle, (void *)_dw_set_focus, handle);
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11529 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11530
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11531 /*
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11532 * Sets the default focus item for a window/dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11533 * Parameters:
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11534 * window: Toplevel window or dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11535 * 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
11536 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11537 * This is for use before showing the window/dialog.
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11538 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11539 void API dw_window_default(HWND window, HWND defaultitem)
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11540 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11541 Box *thisbox = (Box *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11542
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11543 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11544 thisbox->defaultitem = defaultitem;
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11545 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11546
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11547 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11548 * Sets window to click the default dialog item when an ENTER is pressed.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11549 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11550 * window: Window (widget) to look for the ENTER press.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11551 * next: Window (widget) to move to next (or click)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11552 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11553 void API dw_window_click_default(HWND window, HWND next)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11554 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11555 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11556
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11557 if (cinfo)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11558 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11559 cinfo->clickdefault = next;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11560 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11561 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11562
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11563 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11564 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11565 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11566 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11567 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11568 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11569 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11570 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11571 char * API dw_clipboard_get_text(void)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11572 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11573 HANDLE handle;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11574 char *ret = NULL;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11575 TCHAR *tmp;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11576 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11577 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11578 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11579 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11580 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11581
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11582 if ( !OpenClipboard( NULL ) )
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11583 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11584
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11585 if ( ( handle = GetClipboardData(type) ) == NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11586 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11587 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11588 return ret;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11589 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11590
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11591 if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) )
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11592 {
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11593 ret = _strdup(WideToUTF8(tmp));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11594 GlobalUnlock(handle);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11595 }
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11596 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11597 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11598 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11599
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11600 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11601 * Sets the contents of the default clipboard to the supplied text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11602 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11603 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11604 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11605 void API dw_clipboard_set_text( char *str, int len )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11606 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11607 HGLOBAL ptr1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11608 LPTSTR ptr2;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11609 TCHAR *buf;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11610 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11611 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11612 char *src = calloc(len + 1, 1);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11613
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11614 memcpy(src, str, len);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11615 buf = UTF8toWide(src);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11616 free(src);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
11617 len = (int)_tcslen(buf);
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11618 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11619 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11620
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11621 buf = str;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11622 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11623
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11624 if ( !OpenClipboard( NULL ) )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11625 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11626
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11627 ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11628
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11629 if ( !ptr1 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11630 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11631
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11632 ptr2 = GlobalLock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11633
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11634 memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11635 GlobalUnlock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11636 EmptyClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11637
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11638 SetClipboardData( type, ptr1 );
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11639
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11640 CloseClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11641 GlobalFree( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11642 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11643
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11644 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11645 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11646 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11647 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11648 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11649 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11650 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11651 if(!env)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11652 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11654 /* Get the Windows version. */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11655
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11656 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11657 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11658
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11659 /* Get the build number for Windows NT/Windows 2000. */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11660
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11661 env->MinorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11662
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11663 if (dwVersion < 0x80000000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11664 {
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11665 if(env->MajorVersion == 5 && env->MinorVersion == 0)
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11666 strcpy(env->osName, "Windows 2000");
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11667 else if(env->MajorVersion == 5 && env->MinorVersion > 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11668 strcpy(env->osName, "Windows XP");
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11669 else if(env->MajorVersion == 6 && env->MinorVersion == 0)
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11670 strcpy(env->osName, "Windows Vista");
1629
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11671 else if(env->MajorVersion == 6 && env->MinorVersion == 1)
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11672 strcpy(env->osName, "Windows 7");
1629
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11673 else if(env->MajorVersion == 6 && env->MinorVersion > 1)
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11674 strcpy(env->osName, "Windows 8");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11675 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11676 strcpy(env->osName, "Windows NT");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11677
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11678 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11679 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11680 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11681 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11682 strcpy(env->osName, "Windows 95/98/ME");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11683 env->MajorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11684 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11685
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11686 strcpy(env->buildDate, __DATE__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11687 strcpy(env->buildTime, __TIME__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11688 env->DWMajorVersion = DW_MAJOR_VERSION;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11689 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
11690 #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
11691 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
11692 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11693 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
11694 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11695 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11696
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11697 /* Helper to make sure all /s are \s */
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11698 void _to_dos(TCHAR *dst, TCHAR *src)
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11699 {
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11700 int x = 0;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11701
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11702 while(src[x])
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11703 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11704 if(src[x] == TEXT('/'))
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11705 dst[x] = TEXT('\\');
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11706 else
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11707 dst[x] = src[x];
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11708 x++;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11709 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11710 dst[x] = 0;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11711 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11712
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11713 #define BROWSEBUFSIZE 1000
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11714
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11715 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11716 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11717 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11718 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11719 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 * ext: Default file extention.
449
787cc1e27897 Add support for directory browsing under Win32. DW_DIRECTORY_OPEN can be
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 448
diff changeset
11721 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11723 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
11725 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11726 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11727 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11728 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11729 OPENFILENAME of = {0};
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11730 TCHAR filenamebuf[BROWSEBUFSIZE+1] = {0}, *fbuf = filenamebuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11731 TCHAR filterbuf[BROWSEBUFSIZE+1] = {0};
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11732 TCHAR *exten = UTF8toWide(ext);
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11733 TCHAR *dpath = UTF8toWide(defpath);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11734 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11735
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11736 if ( flags == DW_DIRECTORY_OPEN )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11737 {
913
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
11738 /* If we aren't building a DLL, use the more simple browser */
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
11739 #ifndef BUILD_DLL
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11740 BROWSEINFO bi = {0};
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11741 TCHAR szDir[MAX_PATH];
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11742 LPITEMIDLIST pidl;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11743 LPMALLOC pMalloc;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11744
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11745 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11746 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11747 bi.hwndOwner = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11748 bi.pszDisplayName = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11749 bi.pidlRoot = 0;
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11750 bi.lpszTitle = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11751 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11752 bi.lpfn = NULL; /*BrowseCallbackProc*/
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11753
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11754 pidl = SHBrowseForFolder(&bi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11755 if (pidl)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11756 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11757 if (SHGetPathFromIDList(pidl,szDir))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11758 {
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11759 _tcsncpy(filenamebuf,szDir,BROWSEBUFSIZE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11760 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11761
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11762 /* In C++: pMalloc->Free(pidl); pMalloc->Release(); */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11763 pMalloc->lpVtbl->Free(pMalloc,pidl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11764 pMalloc->lpVtbl->Release(pMalloc);
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11765 return _strdup(WideToUTF8(filenamebuf));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11766 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11767 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11768 #else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11769 if ( XBrowseForFolder( NULL,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11770 (LPCTSTR)dpath,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11771 -1,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11772 (LPCTSTR)UTF8toWide(title),
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11773 (LPTSTR)filenamebuf,
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11774 BROWSEBUFSIZE,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11775 FALSE ) )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11776 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11777 return _strdup( WideToUTF8(fbuf) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11778 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11779 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11780 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11781 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11782 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11783 DWORD att = defpath ? GetFileAttributes(UTF8toWide(defpath)) : INVALID_FILE_ATTRIBUTES;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11784
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11785 if (ext)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11786 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11787 /*
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11788 * The following mess is because sprintf() trunates at first \0
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11789 * and format of filter is eg: "c files (*.c)\0*.c\0All Files\0*.*\0\0"
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11790 */
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11791 int len;
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11792 TCHAR *ptr = filterbuf;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11793 TCHAR *start = filterbuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11794
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11795 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("%s Files (*.%s)"), exten, exten );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11796 ptr = ptr + len + 1; /* past first \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11797 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("*.%s"), exten );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11798 ptr = ptr + len + 1; /* past next \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11799 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("All Files") );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11800 ptr = ptr + len + 1; /* past next \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11801 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("*.*") );
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11802 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11803
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11804 memset( &of, 0, sizeof(OPENFILENAME) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11806 of.lStructSize = sizeof(OPENFILENAME);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11807 of.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11808 of.hInstance = DWInstance;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11809 of.lpstrTitle = UTF8toWide(title);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11810 of.lpstrInitialDir = TEXT(".");
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11811 if(att != INVALID_FILE_ATTRIBUTES && (att & FILE_ATTRIBUTE_DIRECTORY))
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11812 of.lpstrInitialDir = dpath;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11813 else if(defpath)
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11814 _to_dos(filenamebuf, dpath);
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11815 of.lpstrFile = filenamebuf;
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11816 of.lpstrFilter = filterbuf;
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11817 of.nFilterIndex = 1;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11818 of.nMaxFile = BROWSEBUFSIZE;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11819 /*of.lpstrDefExt = ext;*/
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11820 of.Flags = OFN_NOCHANGEDIR;
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11821
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11822 if (flags & DW_FILE_SAVE)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11823 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11824 of.Flags |= OFN_OVERWRITEPROMPT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11825 rc = GetSaveFileName(&of);
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11826 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11827 else
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11828 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11829 of.Flags |= OFN_FILEMUSTEXIST;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11830 rc = GetOpenFileName(&of);
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11831 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11832
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11833 if (rc)
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11834 return _strdup(WideToUTF8(of.lpstrFile));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11835 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11836 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11839 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11840 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11841 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11842 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11843 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11844 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11845 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11846 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11847 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11848 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11849 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11850 char **newparams;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11851 int retcode, count = 0, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11853 while(params[count])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11854 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11855 count++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11856 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11857
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11858 newparams = (char **)malloc(sizeof(char *) * (count+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11859
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11860 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11861 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11862 newparams[z] = malloc(strlen(params[z])+3);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11863 strcpy(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11864 strcat(newparams[z], params[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11865 strcat(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11866 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11867 newparams[count] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11868
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11869 /* Why does this return intptr_t ... can the PID exceed an integer value? */
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11870 retcode = (int)_spawnvp(P_NOWAIT, program, (const char * const *)newparams);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11871
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11872 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11873 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11874 free(newparams[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11875 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11876 free(newparams);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11877
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11878 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11879 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11880
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11881 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11882 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11883 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11884 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11885 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11886 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11887 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11888 char *browseurl = url;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11889 int retcode;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11890
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11891 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11892 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11893 int len, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11894
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11895 browseurl = &url[7];
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11896 len = (int)strlen(browseurl);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11897
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11898 for(z=0;z<len;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11899 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11900 if(browseurl[z] == '|')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11901 browseurl[z] = ':';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11902 if(browseurl[z] == '/')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11903 browseurl[z] = '\\';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11904 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11905 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11906
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11907 retcode = DW_POINTER_TO_INT(ShellExecute(NULL, TEXT("open"), UTF8toWide(browseurl), NULL, NULL, SW_SHOWNORMAL));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11908 if(retcode<33 && retcode != 2)
1115
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1090
diff changeset
11909 return DW_ERROR_UNKNOWN;
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1090
diff changeset
11910 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11911 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11912
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11913 typedef struct _dwprint
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11914 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11915 PRINTDLG pd;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11916 DOCINFO di;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11917 int (*drawfunc)(HPRINT, HPIXMAP, int, void *);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11918 void *drawdata;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11919 unsigned long flags;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11920 } DWPrint;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11921
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11922 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11923 * Creates a new print object.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11924 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11925 * 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: 1132
diff changeset
11926 * 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: 1132
diff changeset
11927 * pages: Number of pages to print.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11928 * 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: 1132
diff changeset
11929 * 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: 1132
diff changeset
11930 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11931 * 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: 1132
diff changeset
11932 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11933 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: 1132
diff changeset
11934 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11935 DWPrint *print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11936
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11937 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint))))
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11938 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11939
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11940 print->drawfunc = drawfunc;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11941 print->drawdata = drawdata;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11942 print->pd.lStructSize = sizeof(PRINTDLG);
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11943 print->pd.hwndOwner = HWND_DESKTOP;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11944 print->pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11945 print->pd.nCopies = 1;
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11946 print->pd.nFromPage = 1;
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11947 print->pd.nToPage = pages;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11948 print->pd.nMinPage = 1;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11949 print->pd.nMaxPage = pages;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11950
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11951 if(!PrintDlg(&(print->pd)))
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11952 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11953 free(print);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11954 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11955 }
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11956
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11957 print->di.cbSize = sizeof(DOCINFO);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11958 print->di.lpszDocName = jobname ? UTF8toWide(jobname) : TEXT("Dynamic Windows Print Job");
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11959 return print;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11960 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11961
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11962 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11963 * 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: 1132
diff changeset
11964 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11965 * 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: 1132
diff changeset
11966 * 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: 1132
diff changeset
11967 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11968 * 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: 1132
diff changeset
11969 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11970 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: 1132
diff changeset
11971 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11972 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11973 HPIXMAP pixmap;
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11974 int x, width, height, result = DW_ERROR_UNKNOWN;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11975
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11976 if(!p)
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
11977 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11978
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11979 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
11980 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11981
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11982 width = GetDeviceCaps(p->pd.hDC, HORZRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11983 height = GetDeviceCaps(p->pd.hDC, VERTRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11984
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11985 pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, width, height);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11986 pixmap->hdc = p->pd.hDC;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11987 pixmap->transcolor = DW_RGB_TRANSPARENT;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11988
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11989 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11990 /* Convert the size based on the DPI */
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11991 _convert_dpi(pixmap->hdc, &width, &height, FALSE);
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11992 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11993
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11994 pixmap->width = width;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11995 pixmap->height = height;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11996
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11997 SelectObject(pixmap->hdc, pixmap->hbm);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11998
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11999 /* Start the job */
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12000 StartDoc(p->pd.hDC, &(p->di));
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12001
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12002 /* Cycle through each page */
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12003 for(x=p->pd.nFromPage-1; x<p->pd.nToPage && p->drawfunc; x++)
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12004 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12005 StartPage(p->pd.hDC);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12006 p->drawfunc(print, pixmap, x, p->drawdata);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12007 EndPage(p->pd.hDC);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12008 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12009 if(p->drawfunc)
1338
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12010 {
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12011 result = DW_ERROR_NONE;
1338
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12012 EndDoc(p->pd.hDC);
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12013 }
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12014 else
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12015 AbortDoc(p->pd.hDC);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12016 /* Free memory */
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12017 dw_pixmap_destroy(pixmap);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12018 free(p);
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12019 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12020 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12021
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12022 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12023 * 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: 1132
diff changeset
12024 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12025 * 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: 1132
diff changeset
12026 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12027 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: 1132
diff changeset
12028 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12029 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12030
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12031 if(p)
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12032 p->drawfunc = NULL;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12033 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12034
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12035 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12036 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12037 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12038 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12039 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12040 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12041 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12042 static char _user_dir[1024] = {0};
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12043
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12044 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12045 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12046 HANDLE hToken = 0;
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
12047
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12048 /* Use the Windows API to get the user's profile directory */
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12049 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12050 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12051 DWORD BufSize = 1024;
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12052 TCHAR TmpBuf[1024], *Buf = TmpBuf;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12053
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12054 GetUserProfileDirectory(hToken, Buf, &BufSize);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12055 CloseHandle(hToken);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12056 strncpy(_user_dir, WideToUTF8(Buf), 1023);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12057 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12058 /* If it fails set it to the root directory */
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12059 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12060 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12061 strcpy(_user_dir, "C:\\");
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12062 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12063 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12064 return _user_dir;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12065 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12066
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12067 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12068 * Returns a pointer to a static buffer which containes the
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12069 * private application data directory.
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12070 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
12071 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: 1380
diff changeset
12072 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12073 return _dw_exec_dir;
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12074 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12075
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12076 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12077 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12078 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12079 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12080 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12081 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12082 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12083 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12084 {
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
12085 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12087
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12088 /* Functions for managing the user data lists that are associated with
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12089 * a given window handle. Used in dw_window_set_data() and
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12090 * dw_window_get_data().
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12091 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12092 UserData *_find_userdata(UserData **root, char *varname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12093 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12094 UserData *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12095
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12096 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12097 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12098 if(_stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12099 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12100 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12101 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12102 return NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12103 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12104
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12105 int _new_userdata(UserData **root, char *varname, void *data)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12106 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12107 UserData *new = _find_userdata(root, varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12108
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12109 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12110 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12111 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12112 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12113 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12114 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12115 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12116 new = malloc(sizeof(UserData));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12117 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12118 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12119 new->varname = _strdup(varname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12120 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12121
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12122 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12123
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12124 if (!*root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12125 *root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12126 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12127 {
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: 1297
diff changeset
12128 UserData *prev = *root, *tmp = prev->next;
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: 1297
diff changeset
12129
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12130 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12131 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12132 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12133 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12134 }
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: 1297
diff changeset
12135 prev->next = new;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12136 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12137 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12138 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12139 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12140 return FALSE;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12141 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12142
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12143 int _remove_userdata(UserData **root, char *varname, int all)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12144 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12145 UserData *prev = NULL, *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12146
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12147 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12148 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12149 if(all || _stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12150 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12151 if(!prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12152 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12153 *root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12154 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12155 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12156 if(!all)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12157 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12158 tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12159 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12160 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12161 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12162 /* If all is true we should
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12163 * never get here.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12164 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12165 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12166 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12167 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12168 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12169 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12170 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12171 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12172 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12173 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12174 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12175 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12176 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12177 return 0;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12178 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12179
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12180 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12181 * Add a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12182 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12183 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12184 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12185 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12186 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12187 void API dw_window_set_data(HWND window, char *dataname, void *data)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12188 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12189 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12190
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12191 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12192 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12193 if(!dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12194 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12195
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12196 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12197 cinfo->fore = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12198 SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12199 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12201 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12202 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12203 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12204 _new_userdata(&(cinfo->root), dataname, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12205 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12206 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12207 if(dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12208 _remove_userdata(&(cinfo->root), dataname, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12209 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12210 _remove_userdata(&(cinfo->root), NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12211 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12212 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12213 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12214
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12215 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12216 * Gets a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12217 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12218 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12219 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12220 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12221 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12222 void * API dw_window_get_data(HWND window, char *dataname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12223 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12224 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12225
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12226 if(cinfo && cinfo->root && dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12227 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12228 UserData *ud = _find_userdata(&(cinfo->root), dataname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12229 if(ud)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12230 return ud->data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12231 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12232 return NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12233 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12234
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12235 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12236 * Add a callback to a timer event.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12237 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12238 * interval: Milliseconds to delay between calls.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12239 * sigfunc: The pointer to the function to be used as the callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12240 * data: User data to be passed to the handler function.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12241 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12242 * Timer ID for use with dw_timer_disconnect(), 0 on error.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12243 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12244 int API dw_timer_connect(int interval, void *sigfunc, void *data)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12245 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12246 if(sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12247 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12248 /* Warning: This seems to return UINT_PTR on some systems...
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12249 * which may exceed the storage of int that our API uses.
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12250 */
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12251 int timerid = (int)SetTimer(NULL, 0, interval, _TimerProc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12252
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12253 if(timerid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12254 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12255 _new_signal(WM_TIMER, NULL, timerid, sigfunc, NULL, data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12256 return timerid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12257 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12258 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12259 return 0;
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12260 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12261
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12262 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12263 * Removes timer callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12264 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12265 * id: Timer ID returned by dw_timer_connect().
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12266 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12267 void API dw_timer_disconnect(int id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12268 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12269 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12270
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12271 /* 0 is an invalid timer ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12272 if(!id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12273 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12274
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12275 KillTimer(NULL, id);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12276
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12277 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12278 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12279 if(tmp->id == id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12280 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12281 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12282 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12283 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12284 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12285 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12286 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12287 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12288 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12289 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12290 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12291 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12292 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12293 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12294 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12295 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12296 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12297 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12298 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12299 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12300 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12301
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12302 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12303 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12304 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12305 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12306 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12307 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12308 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12309 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12310 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12311 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12312 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12313 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12314
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12315 /*
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12316 * Add a callback to a window event with a closure callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12317 * Parameters:
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12318 * window: Window handle of signal to be called back.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12319 * signame: A string pointer identifying which signal to be hooked.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12320 * sigfunc: The pointer to the function to be used as the callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12321 * discfunc: The pointer to the function called when this handler is removed.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12322 * data: User data to be passed to the handler function.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12323 */
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12324 void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12325 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12326 ULONG message = 0, id = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12327
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12328 if (window && signame && sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12329 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12330 if (_stricmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12331 window = _normalize_handle(window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12332
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12333 if ((message = _findsigmessage(signame)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12334 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12335 /* Handle special case of the menu item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12336 if (message == WM_COMMAND && window < (HWND)65536)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12337 {
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
12338 char buffer[16];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12339 HWND owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12340
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12341 _snprintf(buffer, 15, "_dw_id%d", (int)(intptr_t)window);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12342 owner = (HWND)dw_window_get_data(DW_HWND_OBJECT, buffer);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12343
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: 1297
diff changeset
12344 /* Make sure there are no dupes from popups */
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: 1297
diff changeset
12345 dw_signal_disconnect_by_window(window);
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: 1297
diff changeset
12346
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12347 if (owner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12348 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12349 id = (ULONG)(uintptr_t)window;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12350 window = owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12351 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12352 }
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12353 _new_signal(message, window, id, sigfunc, discfunc, data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12354 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12355 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12356 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12358 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12359 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12360 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12361 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12362 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12363 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12364 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12365 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12366 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12367
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12368 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12369 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12370
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12371 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12372 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12373 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->message == message)
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
12374 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12375 void (*discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12376
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12377 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12378 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12379 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12380 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12381
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12382 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12383 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12384 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12385 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12386 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12387 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12388 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12389 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12390 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12391 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12392 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12393 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12394 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12395 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12396 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12397 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12398 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12399 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12400 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12401 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12403 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12404 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12405 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12406 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12407 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12408 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12409 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12410 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12411
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12412 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12413 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12414 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12415 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12416 void (*discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12417
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12418 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12419 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12420 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12421 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12422
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12423 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12424 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12425 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12426 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12427 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12428 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12429 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12430 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12431 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12432 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12433 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12434 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12435 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12436 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12437 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12438 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12439 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12440 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12441 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12442 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12444 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12445 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12446 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12447 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12448 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12449 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12450 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12451 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12452 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12453
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12454 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12455 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12456 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data)
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
12457 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12458 void (*discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12459
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12460 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12461 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12462 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12463 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12464
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
12465 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12466 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12467 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12468 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12469 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12470 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12471 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12472 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12473 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12474 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12475 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12476 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12477 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12478 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12479 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12480 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12481 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12482 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12483 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12484 }
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12485
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12486 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12487 * Converts a UTF-8 encoded string into a wide string.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12488 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12489 * utf8string: UTF-8 encoded source string.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12490 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12491 * 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: 1769
diff changeset
12492 * or NULL on failure.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12493 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12494 wchar_t * API dw_utf8_to_wchar(char *utf8string)
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12495 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12496 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12497 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)));
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12498 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12499 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12500 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12501 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12502
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12503 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12504 * Converts a wide string into a UTF-8 encoded string.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12505 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12506 * wstring: Wide source string.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12507 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12508 * 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: 1769
diff changeset
12509 * or NULL on failure.
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12510 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12511 char * API dw_wchar_to_utf8(wchar_t *wstring)
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12512 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12513 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12514 return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL)));
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12515 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12516 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12517 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12518 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12519