annotate win/dw.c @ 1846:905f8632005b

When handling click default, return instead of running the default handler on Windows. The default handler causes a bell sound on some versions of Windows...
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 27 Dec 2012 13:03:47 +0000
parents 123d1a900f54
children 4790589f52a9
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 *
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
5 * (C) 2000-2012 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;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
339 void *data;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 SignalHandler *Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
347 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
348 char name[30];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
352 static int in_checkbox_handler = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
353
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
354 /* 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
355 #define SIGNALMAX 17
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 SignalList SignalTranslate[SIGNALMAX] = {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
358 { WM_SIZE, DW_SIGNAL_CONFIGURE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
359 { WM_CHAR, DW_SIGNAL_KEY_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
360 { WM_LBUTTONDOWN, DW_SIGNAL_BUTTON_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
361 { WM_LBUTTONUP, DW_SIGNAL_BUTTON_RELEASE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
362 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
363 { WM_CLOSE, DW_SIGNAL_DELETE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
364 { WM_PAINT, DW_SIGNAL_EXPOSE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
365 { WM_COMMAND, DW_SIGNAL_CLICKED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
366 { NM_DBLCLK, DW_SIGNAL_ITEM_ENTER },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
367 { NM_RCLICK, DW_SIGNAL_ITEM_CONTEXT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
368 { LBN_SELCHANGE, DW_SIGNAL_LIST_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
369 { TVN_SELCHANGED, DW_SIGNAL_ITEM_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
370 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
371 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
372 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
373 { LVN_COLUMNCLICK, DW_SIGNAL_COLUMN_CLICK },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
374 { TVN_ITEMEXPANDED,DW_SIGNAL_TREE_EXPAND }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376
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
377 #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
378 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
379 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
380 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
381 }
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 #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
383 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
384 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
385 char *tmp, *argstart, **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
386 int loc = 0, inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
387
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
388 (*count) = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
389
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
390 tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
391
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
392 /* Count the number of entries */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
393 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
394 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
395 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
396
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
397 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
398 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
399 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
400 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
401 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
402 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
403 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
404 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
405 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
406 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
407 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
408 /* 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
409 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
410 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
411 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
412 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
413 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
414 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
415 }
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 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
419 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
420 GetModuleFileNameA(DWInstance, argv[0], 260);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
421
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
422 argstart = tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
423
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
424 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
425 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
426 loc = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
427
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
428 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
429 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
430 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
431 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
432 *tmp = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
433 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
434 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
435 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
436 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
437 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
438 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
439 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
440 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
441 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
442 *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
443 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
444
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
445 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
446 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
447 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
448
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
449 /* Move the start pointer */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
450 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
451
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
452 /* 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
453 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
454 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
455 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
456 loc++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
457 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
458 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
459 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
460 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
461 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
462 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
463 argv[loc+1] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
464 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
465 }
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 /* 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
468 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
469 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
470 char **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
471 int argc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
472
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
473 DWInstance = hInstance;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
474
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
475 argv = _convertargs(&argc, lpCmdLine);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
476
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
477 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
478 }
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 #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
480
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
481 #ifdef UNICODE
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
482 /* 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
483 #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
484 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
485 {
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
486 LPWSTR retbuf = outbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
487
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
488 if(retbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
489 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
490 return retbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
491 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
492 #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
493 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
494 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
495 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
496
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
497 if(retbuf)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
498 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
499 return retbuf;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
500 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
501 #else
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
502 #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
503 #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
504 #endif
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
505
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
506 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
507 {
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
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
509 HINSTANCE hinstDll;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
510 DWORD dwVersion = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
511
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
512 hinstDll = LoadLibrary(lpszDllName);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
513
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
514 if(hinstDll)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
515 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
516 DLLGETVERSIONPROC pDllGetVersion;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
517
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
518 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
520 /* 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
521 * 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
522 * 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
523 * indicator of the version.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
524 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
525 if(pDllGetVersion)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
526 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
527 DLLVERSIONINFO dvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
528 HRESULT hr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
529
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
530 ZeroMemory(&dvi, sizeof(dvi));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
531 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
532
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 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
534
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
535 if(SUCCEEDED(hr))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
536 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
537 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
538 }
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 FreeLibrary(hinstDll);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
542 }
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
543 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
544 }
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
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
546 #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
547 /*
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 * 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
549 * 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
550 * 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
551 */
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
552 #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
553 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
554 {
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
555 "",
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
556 ".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
557 ".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
558 ".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
559 ".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
560 ".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
561 ".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
562 ".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
563 };
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 /* 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
566 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
567 {
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
568 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
569 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
570 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
571 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
572
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 /* 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
574 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
575 {
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 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
577 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
578 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
579 {
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 /* 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
581 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
582 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
583 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
584 }
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 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
587 }
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 /* 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
590 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
591 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
592 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
593 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
594 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
595 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
596
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
597 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
598 {
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 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
600 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
601 INT pf;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
602
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
603 /* 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
604 *depth = 0;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
605
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
606 /* 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
607 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
608 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
609 switch(pf)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
610 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
611 case PixelFormat1bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
612 *depth = 1;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
613 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
614 case PixelFormat4bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
615 *depth = 4;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
616 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
617 case PixelFormat8bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
618 *depth = 8;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
619 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
620 case PixelFormat16bppGrayScale:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
621 case PixelFormat16bppRGB555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
622 case PixelFormat16bppRGB565:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
623 case PixelFormat16bppARGB1555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
624 *depth = 16;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
625 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
626 case PixelFormat24bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
627 *depth = 24;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
628 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
629 case PixelFormat32bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
630 case PixelFormat32bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
631 case PixelFormat32bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
632 case PixelFormat32bppCMYK:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
633 *depth = 32;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
634 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
635 case PixelFormat48bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
636 *depth = 48;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
637 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
638 case PixelFormat64bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
639 case PixelFormat64bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
640 *depth = 64;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
641 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
642 }
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
643 }
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
644 }
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 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
646 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
647 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
648 }
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 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
650 }
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 /* 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
653 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
654 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
655 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
656 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
657 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
658 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
659
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
660 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
661 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
662 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
663 }
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 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
665 }
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 #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
667
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 */
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
670 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
672 SignalHandler *new = malloc(sizeof(SignalHandler));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
673
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
674 new->message = message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
675 new->window = window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
676 new->id = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
677 new->signalfunction = signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
678 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
679 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
680
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
681 if (!Root)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
682 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
683 Root = new;
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
686 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
687 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
688 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
689 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
690 if(tmp->message == message &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
691 tmp->window == window &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
692 tmp->id == id &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
693 tmp->signalfunction == signalfunction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
694 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
695 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
696 free(new);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
697 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
698 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
699 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
700 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
701 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
702 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
703 prev->next = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
704 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
705 Root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
706 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
712 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
713
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
714 for(z=0;z<SIGNALMAX;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
715 {
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
716 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
717 return SignalTranslate[z].message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
718 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
719 return 0L;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
722 /* 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
723 * the user memory and resources allocated to it.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 */
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
725 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
726 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
727 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
728 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
729 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
730 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
731
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
732 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
733
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 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
735 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
736 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
737
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 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
739
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
740 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
741
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
742 /* 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
743 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
744 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
745
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
746 /* 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
747 if(oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
748 DeleteObject(oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
749 if(oldicon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
750 DeleteObject(oldicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
751
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
752 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
753 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
754 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
755
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
756 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
757 DeleteObject(oldbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
758 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
759 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
760 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
761 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
762 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
763
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
764 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
765 DeleteObject(oldbitmap);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
766 if(oldicon)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
767 DestroyIcon(oldicon);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
768 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
769 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
770 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
771 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
772 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
773 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
774 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
775
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
776 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
777 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
778
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
779 if(imlist)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
780 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
781 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
782 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
783 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
784 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
785 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
786 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
787 Box *box = (Box *)thiscinfo;
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 if(box && box->count && box->items)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
790 free(box->items);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
791 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
792 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
793 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
794 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
795
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
796 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
797 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
798 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
799 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
800 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
801 dw_tree_clear(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
802 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
803 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
804 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
805 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
806
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
807 if(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 int z;
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 for(z=0;z<256;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 if(array[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 _free_window_memory(array[z]->hwnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
816 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
817 DestroyWindow(array[z]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
818 free(array[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
819 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
820 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
821 free(array);
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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
824 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
825 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
826 /* 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
827 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
828
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
829 if(cinfo && cinfo->buddy)
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
830 DestroyWindow( cinfo->buddy );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
831 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
833 dw_signal_disconnect_by_window(handle);
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 if(thiscinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
836 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
837 if(thiscinfo->pOldProc)
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
838 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
839
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
840 /* 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
841 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
842 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
843
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
844 /* Free user data linked list memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
845 if(thiscinfo->root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
846 dw_window_set_data(handle, NULL, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
847
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
848 SetWindowLongPtr(handle, GWLP_USERDATA, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
849 free(thiscinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
850 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
851 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853
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
854 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
855 {
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
856 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
857
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 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
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 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
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 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
863 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
864
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 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
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 /* 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
868 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
869 {
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 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
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 _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
873 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
874 _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
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_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
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_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
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 }
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
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 /* 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
883 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
884 _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
885 }
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
886 }
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
887 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
888 }
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
889
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
890 /* 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
891 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
892 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
893 if(color == DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
894 return DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
895 if(color < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
896 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
897 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
898 }
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
899
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
905 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
906
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
907 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
908 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
909
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
910 if(!IsWindowEnabled(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
911 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
912
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
913 GetClassName(handle, tmpbuf, 99);
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 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
916 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
917 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
918 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
919 _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
920 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
921 _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
922 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
923 _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
924 _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
925 _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
926 _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
927 _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
928 _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
929 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
930 /* 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
931 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
932 return 2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
933 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935
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
936 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
937 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
938 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
939
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
940 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
941 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
942 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
943 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
946 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
947 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
948 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
949 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
950 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
953 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
954 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
955 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
956 }
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
957
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
958 #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
959 #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
960
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
961 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
962
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
963 /* 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
964 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
965 {
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
966 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
967 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
968 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
969 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
970
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
971 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
972 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
973 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
974 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
975
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
976 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
977 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
978 Box *notebox;
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 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
981 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
982 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
983
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
984 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
985 return 1;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
986 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
987 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
988 return 0;
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
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
991 /* 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
992 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
994 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
995 static HWND lasthwnd, firsthwnd;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
996 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
997 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
998 int end = (direction == _DW_DIRECTION_FORWARD) ? -1 : box->count;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1000 /* 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
1001 * 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
1002 * that was valid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1003 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1004 if(start == 2)
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(lasthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1007 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1008 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1009 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1010
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1011 /* 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
1012 * 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
1013 * the function recursively.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1014 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1015 if(start == 1)
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 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1018 finish_searching = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1019 firsthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1020 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1021
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1022 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
1023 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1024 if(box->items[z].type == TYPEBOX)
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 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
1027
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1028 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
1029 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1030 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1031 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1032 {
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1033 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
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 /* 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
1036 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
1037 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1038 if(box->items[z].hwnd == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1039 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1040 if(lasthwnd == handle && firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1041 SetFocus(firsthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1042 else if(lasthwnd == handle && !firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1043 finish_searching = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1044 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1045 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1046
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1047 /* 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
1048 * return immediately.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1049 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1050 if(!finish_searching)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1051 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1052 }
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1053 if(type > 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1054 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1055 /* 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
1056 * first valid item in the layout.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1057 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1058 if(start == 3)
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(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
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 SetFocus(_normalize_handle(box->items[z].hwnd));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1063 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1064 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1065 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1066
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1067 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
1068
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1069 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
1070 firsthwnd = lasthwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1071 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1072 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1073 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1074 /* 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
1075 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1076
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1077 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1078
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1079 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
1080 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1081 /* 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
1082 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
1083
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1084 if(mybox)
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 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1087
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1088 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
1089 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1090 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1091
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1092 /* 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
1093 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
1094
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1095 if(mybox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1096 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1097 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
1098
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1099 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
1100 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1101 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1102 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1103 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
1104 {
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1105 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
1106 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
1107
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1108 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
1109 return 1;
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1110 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1111 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1112 /* 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
1113 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
1114 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1115 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1116 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1117 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
1118 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1119
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 */
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
1123 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
1124 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1125 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
1126 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1127
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1128 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1129 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1130
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1131 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1132
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1133 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
1134 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1135
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1136
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1137 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1138 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1139
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1140 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1141 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1142 _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
1143 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1146 HWND _toplevel_window(HWND handle)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1147 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1148 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1149
1803
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1150 if(!lastbox)
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1151 lastbox = handle;
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1152
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1153 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1154 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1155 {
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1156 /* 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
1157 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
1158 return 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1159 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1160 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1161 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
1162 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1163 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
1164
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1165 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
1166
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1167 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
1168 return lastbox;
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1169 }
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1170 return 0;
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1171 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1172
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 */
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1176 void _shift_focus(HWND handle, int direction)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1178 Box *thisbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1179
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1180 HWND box, lastbox = GetParent(handle);
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 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1183 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1184 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1185 lastbox = box;
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1188 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1189 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1190 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1191 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
1192 _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
1193 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1194 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1195
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 */
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
1199 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
1200 {
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 /* 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
1202 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
1203 /* 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
1204 * 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
1205 * 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
1206 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1207 int uymax = 0, uxmax = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1208 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
1209
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
1210 /* 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
1211 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
1212
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1213 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1214 {
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
1215 /* 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
1216 * 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
1217 */
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
1218 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
1219 {
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 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
1221
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
1222 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
1223
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
1224 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
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 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
1228 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
1229 }
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 /* 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
1231 * 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
1232 */
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 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
1234 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
1235
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
1236 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
1237 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
1238 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
1239 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
1240
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->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
1242 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1243
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
1244 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
1245 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
1246 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
1247 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
1248 }
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
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 /* 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
1251 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1252 {
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
1253 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
1254
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1255 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1256 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1257 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
1258
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1259 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1260 {
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
1261 /* 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
1262 if(pass == 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1263 {
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
1264 (*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
1265
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 /* 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
1267 _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
1268
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 /* 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
1270 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
1271 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
1272
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
1273 /* 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
1274 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
1275 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
1276 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
1277 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
1278
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
1279 (*depth)--;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1280 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1281 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1282 }
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
1283
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
1284 /* 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
1285 * 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
1286 */
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 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
1288 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
1289 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
1290
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 /* Calculate the totals and maximums */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1292 if(thisbox->type == DW_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1293 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1294 if(itemwidth > uxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1295 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
1296
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1297 if(thisbox->items[z].hsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1298 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1299 if(itemwidth > upxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1300 upxmax = itemwidth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1301 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1302 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1303 {
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
1304 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
1305 upxmax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1306 }
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
1307 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
1308 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
1309 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
1310 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
1311 thisbox->usedpady += itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1312 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1313 else
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 if(itemheight > uymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1316 uymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1317 if(thisbox->items[z].vsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1318 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1319 if(itemheight > upymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1320 upymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1321 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1322 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1323 {
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
1324 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
1325 upymax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1326 }
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
1327 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
1328 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
1329 thisbox->usedpadx += itemwidth;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1330 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
1331 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
1332 }
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 }
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 /* 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
1336 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
1337 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
1338 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
1339 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
1340
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 /* 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
1342 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1343 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1344 currentx += 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1345 currenty += thisbox->grouppady - 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1346 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1347
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
1348 /* 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
1349 if(pass > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1350 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1351 for(z=0;z<(thisbox->count);z++)
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 int height = thisbox->items[z].height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1354 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
1355 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
1356 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
1357
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 /* 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
1359 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
1360 {
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->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
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 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
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 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
1366 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
1367 }
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 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
1369 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
1370 }
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 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
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->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
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 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
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 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
1378 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
1379 }
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 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
1381 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
1382 }
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
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 /* 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
1385 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
1386 {
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 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
1388 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
1389 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
1390
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1391 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1392
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1393 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
1394 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1395 /* Handle special case Combobox */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1396 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
1397 width, height + 400, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1398 }
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1399 #ifdef TOOLBAR
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1400 /* Bitmap Buttons */
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1401 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
1402 {
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
1403 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
1404
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 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
1406 }
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1407 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1408 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
1409 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1410 /* Handle special case Spinbutton */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1411 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1412
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
1413 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
1414 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1415
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1416 if(cinfo)
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 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
1419 width - 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1420 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1421 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1422 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
1423 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1424 /* Handle special case of scrollbox */
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1425 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
1426 int cx, cy, depth = 0;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1427 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
1428 SCROLLINFO hsi, vsi;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1429 RECT rect;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1430
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1431 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
1432 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
1433
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1434 /* 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
1435 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
1436 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
1437
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1438 /* 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
1439 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
1440
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1441 GetClientRect(handle, &rect);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1442 cx = rect.right;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1443 cy = rect.bottom;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1444
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1445
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1446 /* 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
1447 _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
1448
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 if(cx < thisbox->minwidth)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1450 {
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
1451 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 if(cy < thisbox->minheight)
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 cy = thisbox->minheight;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1456 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1457
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1458 /* 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
1459 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
1460 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
1461 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
1462 {
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
1463 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
1464 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
1465 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
1466 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1467 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 }
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
1470 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
1471 {
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
1472 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
1473 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
1474 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
1475 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1476 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 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1479 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
1480 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
1481 SetScrollInfo(handle, SB_VERT, &vsi, TRUE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1482
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1483 /* Layout the content of the scrollbox */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1484 _do_resize(thisbox, cx, cy);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1485 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1486 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
1487 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1488 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1489 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
1490 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
1491
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1492 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
1493 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
1494
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
1495 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
1496 _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
1497 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1498 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
1499 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1500 /* Handle special case Vertically Center static text */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1501 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1502
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1503 if(cinfo && cinfo->vcenter)
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 /* 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
1506 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
1507 int textheight, diff, total = height;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1508
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1509 GetWindowText(handle, thisbuf, 1023);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1510
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1511 /* 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
1512 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
1513
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1514 diff = (total - textheight) / 2;
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 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
1517 width, height - diff, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1518 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1519 else
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 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
1522 width, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1523 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1524 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1525 else
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 /* 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
1528 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
1529 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
1530 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
1531 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
1532
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
1533 /* 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
1534 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1535 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1536 Box *boxinfo = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1537
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
1538 if(boxinfo)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
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 /* 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
1541 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
1542 {
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 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
1544 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
1545 }
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 /* 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
1547 (*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
1548 _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
1549 (*depth)--;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1550 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1551 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1552 }
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 /* 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
1555 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
1556 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1557 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1558 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
1559 int pageid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1560
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1561 if(pageid > -1 && array && array[pageid])
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 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1564 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1565 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
1566 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
1567 dw_window_redraw(array[pageid]->hwnd);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1568 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1569 }
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
1570 /* 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
1571 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
1572 {
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
1573 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
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 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
1576 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
1577 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1578
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
1579 /* 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
1580 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
1581 currentx += width + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1582 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
1583 currenty += height + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1584 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1585 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1586 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1591 if(x != 0 && y != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1592 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1593 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1594 {
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
1595 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
1596
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 /* 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
1598 _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
1599
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 /* 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
1601 _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
1602 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1603 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1606 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
1607 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1608 SCROLLINFO si;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1609
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1610 ZeroMemory( &si, sizeof(si) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1611 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1612 si.fMask = SIF_ALL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1613
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1614 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
1615
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1616 switch(which)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1617 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1618 case SB_THUMBTRACK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1619 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1620 /*case SB_PAGEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1621 case SB_PAGELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1622 pos = si.nPos - si.nPage;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1623 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1624 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1625 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1626 /*case SB_PAGEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1627 case SB_PAGERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1628 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
1629 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
1630 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1631 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1632 /*case SB_LINEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1633 case SB_LINELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1634 pos = si.nPos - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1635 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1636 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1637 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1638 /*case SB_LINEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1639 case SB_LINERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1640 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
1641 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
1642 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1643 return pos;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1644 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1645 return -1;
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1646 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1647
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
1648 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
1649 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1650 MENUINFO mi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1651
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1652 mi.cbSize = sizeof(MENUINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1653 mi.fMask = MIM_MENUDATA;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1654
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
1655 if ( GetMenuInfo( menu, &mi ) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1656 return (HMENU)mi.dwMenuData;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1657 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
1658 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1659
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 /* 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
1661 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
1662 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1663 HMENU menuowner = 0, lastowner = _get_owner(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1664
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1665 /* Find the toplevel menu */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1666 while((menuowner = _get_owner(lastowner)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1667 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1668 if(menuowner == (HMENU)1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1669 return lastowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1670 lastowner = menuowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1671 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1672 return (HMENU)0;
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
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 * 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
1677 * 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
1678 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1679 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
1680 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1681 char buffer[40];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1682 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
1683 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
1684 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
1685 if ( checkable )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1686 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1687 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
1688 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
1689 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
1690 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
1691 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
1692 }
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
1693 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1694
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
1695 /* 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
1696 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
1697 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1698 int result = -1, taskbar = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1699 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1700 void (*windowfunc)(PVOID);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1701 ULONG origmsg = msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1702
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1703 /* Deal with translating some messages */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1704 if (msg == WM_USER+2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1705 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1706 taskbar = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1707 origmsg = msg = (UINT)mp2; /* no else here */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1708 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1709 if (msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1710 msg = WM_LBUTTONDOWN;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1711 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
1712 msg = WM_LBUTTONUP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1713 else if (msg == WM_HSCROLL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1714 msg = WM_VSCROLL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1715 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
1716 msg = WM_CHAR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1717
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1718 if (result == -1)
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1721 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1722 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1723 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
1724 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1725 switch (msg)
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 case WM_TIMER:
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 if (!hWnd)
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 int (*timerfunc)(void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1732 if (tmp->id == (int)mp1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1733 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1734 if (!timerfunc(tmp->data))
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1735 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1736 dw_timer_disconnect(tmp->id);
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 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1739 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1740 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1741 result = 0;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1744 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1745 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1746 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
1747
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1748 if(hWnd == tmp->window)
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 result = setfocusfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1751 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1752 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1753 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1754 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1755 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1756 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1757 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
1758 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1759 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1760 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
1761 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1762 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1763 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1764 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1765 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1766 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1767 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
1768
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1769 if(hWnd == tmp->window)
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 int button=0;
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 switch(origmsg)
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 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1776 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1777 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1778 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1779 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1780 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1781 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1782 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1783 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1784 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1785 if(taskbar)
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 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1788 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1789 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
1790 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1791 else
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 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1794 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
1795 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1796 tmp = NULL;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1799 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1800 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1801 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1802 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
1803
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1804 if(hWnd == tmp->window)
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 int button=0;
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 switch(origmsg)
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 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1811 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1812 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1813 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1814 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1815 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1816 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1817 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1818 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1819 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1820 if(taskbar)
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 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1823 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1824 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
1825 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1826 else
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 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1829 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
1830 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1831 tmp = NULL;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1834 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1835 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1836 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1837 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1838 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
1839
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1840 if(hWnd == tmp->window)
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 int keys = 0;
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 if (mp1 & MK_LBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1845 keys = DW_BUTTON1_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1846 if (mp1 & MK_RBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1847 keys |= DW_BUTTON2_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1848 if (mp1 & MK_MBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1849 keys |= DW_BUTTON3_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1851 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
1852 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1853 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1854 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1855 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1856 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1857 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1858 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
1859
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1860 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
1861 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1862 int special = 0;
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1863 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
1864 #ifdef UNICODE
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1865 WCHAR uc[2] = { 0 };
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1866
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1867 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
1868 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
1869 #endif
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1870
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1871 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1872 special |= KC_SHIFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1873 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1874 special |= KC_CTRL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1875 if(mp2 & (1 << 29))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1876 special |= KC_ALT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1877
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1878 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
1879 ch[0] = (char)mp1;
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1880
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1881 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
1882 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1883 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1884 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1885 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1886 case WM_CLOSE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1887 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1888 int (*closefunc)(HWND, void *) = tmp->signalfunction;
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 if(hWnd == tmp->window)
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 result = closefunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1893 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1894 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1895 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1896 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1897 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1898 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1899 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1900 DWExpose exp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1901 int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1902
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1903 if ( hWnd == tmp->window )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1904 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1905 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1906 exp.x = ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1907 exp.y = ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1908 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
1909 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
1910 result = exposefunc(hWnd, &exp, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1911 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1912 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1913 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1914 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1915 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1916 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1917 if(tmp->message == TVN_SELCHANGED ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1918 tmp->message == NM_RCLICK ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1919 tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1920 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1921 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1922 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
1923 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1924
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1925 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1926
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1927 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
1928 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1929 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
1930 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1931 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
1932 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1933 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
1934 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1935 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1936
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
1937 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1938 tvi.hItem = tem->itemNew.hItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1939
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1940 TreeView_GetItem(tmp->window, &tvi);
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1943 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1944 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
1945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1946 tmp = NULL;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1949 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
1950 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1951 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
1952 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1953 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = tmp->signalfunction;
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 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
1956 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1957 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1958 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1959 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
1960 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1961 if(tmp->window == tem->hdr.hwndFrom)
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 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
1964 HTREEITEM hti;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1965 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1966 TVHITTESTINFO thi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1967 void **ptrs = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1968 LONG x, y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1969
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1970 dw_pointer_query_pos(&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 thi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1973 thi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1974
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1975 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
1976
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1977 hti = TreeView_HitTest(tmp->window, &thi);
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 if(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1980 {
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
1981 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1982 tvi.hItem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1983
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1984 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1985 TreeView_SelectItem(tmp->window, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1986
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1987 ptrs = (void **)tvi.lParam;
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 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
1990 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1991 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1992 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1993 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1994 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
1995 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1996 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
1997 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1998 if(tmp->window == tem->hdr.hwndFrom)
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 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2001 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2002
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2003 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
2004
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2005 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
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 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
2010
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2011 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2012 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2013
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2014 ListView_GetItem(tmp->window, &lvi);
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 /* 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
2017 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2018 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2019
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2020 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
2021 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2022 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2023 }
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 else if(tmp->message == TCN_SELCHANGE)
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 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2030 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
2031 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2032 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
2033 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
2034 result = switchpagefunc(tem->hwndFrom, num, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2035 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2036 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2037 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2038 else if(tmp->message == LVN_COLUMNCLICK)
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 NMLISTVIEW FAR *tem=(NMLISTVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2041 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
2042 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2043 int (*columnclickfunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2044 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
2045 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2046 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2047 }
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2048 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
2049 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2050 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
2051 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
2052 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2053 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
2054 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
2055 tmp = NULL;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2056 }
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2057 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2058 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2059 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2060 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2061 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2062 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2063 HWND command;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2064 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
2065 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
2066
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2067 command = (HWND)(uintptr_t)passthru;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2068
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2069 if (message == LBN_SELCHANGE || message == CBN_SELCHANGE)
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 int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
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 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
2074 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2075 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
2076 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2077 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2078 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2079 #ifdef TOOLBAR
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2080 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
2081 {
1760
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2082 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
2083
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2084 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
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 /* 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
2087 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
2088 {
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2089 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
2090 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
2091 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2092 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2093 #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
2094 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
2095 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2096 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
2097
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2098 if (menuowner == hwndmenu || !menuowner)
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 _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
2101 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2102 * Call the user supplied callback
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2103 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2104 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
2105 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2106 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2107 } /* this fires for checkable menu items */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2108 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
2109 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2110 _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
2111 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
2112 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2113 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2114 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2115 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2116 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2117 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2118 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2119 TCHAR tmpbuf[100] = {0};
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2120 HWND handle = (HWND)mp2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2121 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2122
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2123 if(!GetClassName(handle, tmpbuf, 99))
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2124 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2125 GetClassName(hWnd, 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
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2128 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
2129 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2130
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2131 if (handle == tmp->window)
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 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
2134 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
2135 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2136
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2137 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2138 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
2139 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2140 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2141 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2142 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2143 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2144 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
2145 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2146 if(handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2147 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2148 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
2149 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
2150
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2151 if(value > -1)
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 dw_scrollbar_set_pos(tmp->window, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2154 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2155 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2156 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2157 msg = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2158 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2159 }
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 break;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2164 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2165 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2166 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2167 }
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 /* 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
2170 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2171 {
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
2172 #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
2173 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
2174 {
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
2175 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
2176
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2177 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
2178 _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
2179
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2180 /* 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
2181 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
2182 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2183 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
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 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
2186 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
2187 _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
2188 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2189 }
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
2190 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
2191 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2192 #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
2193 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
2194 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
2195 {
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
2196 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
2197 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
2198
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 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2200 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
2201
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
2202 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
2203 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
2204 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
2205 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2206 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
2207 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2208 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2209 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2210 PAINTSTRUCT ps;
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 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2213 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2214 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2215 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2216 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2217 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2218 static int lastx = -1, lasty = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2219 static HWND lasthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2220
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2221 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
2222 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2223 Box *mybox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 if(mybox && mybox->count)
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 lastx = LOWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2228 lasty = HIWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2229 lasthwnd = hWnd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2230
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2231 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2232 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2233 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2234 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2235 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2236 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2239 case WM_USER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2240 windowfunc = (void *)mp1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2242 if(windowfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2243 windowfunc((void *)mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2244 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2245 case WM_USER+5:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2246 _free_menu_data((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2247 DestroyMenu((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2248 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2249 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2250 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2251 NMHDR FAR *tem=(NMHDR FAR *)mp2;
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 if(tem->code == TCN_SELCHANGING)
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 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2256 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
2257
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2258 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2259 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2260
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2261 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2262 else if(tem->code == TCN_SELCHANGE)
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 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2265 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
2266
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2267 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2268 SetParent(array[num]->hwnd, tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2269
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2270 _resize_notebook_page(tem->hwndFrom, num);
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2273 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2274 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2275 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2276 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2277 HWND handle = (HWND)mp2;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2278 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
2279
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2280 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
2281 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2282 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
2283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2284 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2285 dw_scrollbar_set_pos(handle, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2286 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2287 else
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2288 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2289 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
2290
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2291 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
2292 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
2293 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2294 _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
2295 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2296 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2297 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2298 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2299 case WM_GETMINMAXINFO:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2300 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2301 MINMAXINFO *info = (MINMAXINFO *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2302 info->ptMinTrackSize.x = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2303 info->ptMinTrackSize.y = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2304 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2305 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2306 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2307 case WM_DESTROY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2308 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2309 HMENU menu = GetMenu(hWnd);
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 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2312 _free_menu_data(menu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2313
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2314 /* Free memory before destroying */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2315 _free_window_memory(hWnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2316 EnumChildWindows(hWnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2317 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2318 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2319 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2320 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2321 HCURSOR cursor;
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 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
2324 (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
2325 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2326 SetCursor(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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2329 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2330 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2331 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2332 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2333 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2334 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2335 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2336 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2337 return _colorwndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2338 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2339 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
2340 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2341 /* 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
2342 _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
2343 /* Then finally return */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2344 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
2345 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2346 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
2347 }
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
2348
461
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2349 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
2350 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2351 _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
2352 }
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2353
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
2354 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
2355 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2356 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2357 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2358 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2359 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2360 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2361 SetActiveWindow(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2362 SetFocus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2363 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2364 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2365 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2366 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2367 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2368 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
2369 #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
2370 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
2371 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
2372 {
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
2373 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
2374 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
2375
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 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2377 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
2378
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
2379 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
2380 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
2381 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
2382 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2383 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
2384 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2385 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2386 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2387 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 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
2390 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2391 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2392 HDC hdcPaint = BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2393 int success = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2394
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2395 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
2396 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2397 /* Handle foreground */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2398 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2399 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2400 if(thiscinfo->fore != DW_CLR_DEFAULT)
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 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2403 _green[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2404 _blue[thiscinfo->fore]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2405 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2406 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2407 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
2408 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2409 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
2410 DW_GREEN_VALUE(thiscinfo->fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2411 DW_BLUE_VALUE(thiscinfo->fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2412 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2413 /* Handle background */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2414 if(thiscinfo->back > -1 && thiscinfo->back < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2415 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2416 if(thiscinfo->back != DW_CLR_DEFAULT)
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 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2419 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2420 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2421 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2422 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2423 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2424 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2425 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2426 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2427 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
2428 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2429 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2430 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2431 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
2432 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2433 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
2434 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2435 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2436 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2437 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2438 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
2439 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2440 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2441 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2442 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
2443 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2444 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2445 }
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 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2448 if(success)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2449 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2450 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2451
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 break;
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 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
2456 }
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
2457
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
2458 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
2459 {
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 rcode = TRUE;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2461
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2462 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2463 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2464 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2465 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2466 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2467 SetFocus(hWnd);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2468 rcode = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2469 break;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2470 case WM_MOUSEMOVE:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2471 /* 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
2472 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
2473 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
2474 case WM_USER+2:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2475 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2476 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2477 case WM_RBUTTONUP:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2478 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
2479 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2480 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2481 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2482 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2483 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2484 case WM_KEYDOWN:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2485 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
2486 break;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2487 default:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2488 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2489 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2490 /* 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
2491 if ( rcode != 0 )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2492 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
2493 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
2494 }
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
2495
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
2496 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
2497 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2498 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2499
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2500 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 if(msg == WM_MOUSEMOVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2503 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2504
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2505 if(cinfo)
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 switch( msg )
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 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2510 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2511 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2512 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2513 {
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
2514 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2515
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2516 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2517 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2518 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
2519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2520 /* 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
2521 * 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
2522 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2523 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2524 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
2525
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2526 SetTimer(hWnd, 100, 100, (TIMERPROC)NULL);
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 return ret;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2531 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2532 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2533 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2534 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2535 {
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
2536 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2537
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2538 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2539 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2540 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
2541
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2542 /* 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
2543 * 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
2544 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2545 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2546 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
2547
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2548 if(hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2549 KillTimer(hWnd, 100);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2550
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2551 return ret;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2554 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2555 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2556 if(mp1 == 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2557 {
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
2558 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2559
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2560 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2561 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
2562
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2563 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2564 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2565 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
2566
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2567 /* 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
2568 * 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
2569 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2570 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2571 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
2572
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2573 return ret;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2576 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2577 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2578 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2579 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2580 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2581 TCHAR tempbuf[100] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2582 long position;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2583
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2584 GetWindowText(cinfo->buddy, tempbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2585
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2586 position = _tstol(tempbuf);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2587
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
2588 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
2589 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2590 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2591 break;
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 }
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 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2596 return DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2597 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2600 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
2601 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2602 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2603
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2604 GetClassName(handle, tmpbuf, 99);
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 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2607 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2608 */
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2609 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
2610 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2611 || _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
2612 #endif
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2613 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2614 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2615 /* Generate click on default item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2616 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2618 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2619 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2620 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2621 if (tmp->message == WM_COMMAND)
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 /* 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
2624 if (tmp->window == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2625 {
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2626 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2627 clickfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2628 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2629 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2630 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2631 if (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2632 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2633 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2634 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2635 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2636 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
2637 }
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
2638
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2639 /* 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
2640 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
2641 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2642 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
2643 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2644 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
2645 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2646
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2647 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 GetClassName(hWnd, tmpbuf, 99);
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2650 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
2651 cinfo = &(((Box *)cinfo)->cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2652
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
2653 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
2654 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2655
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2656 if (cinfo)
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 pOldProc = cinfo->pOldProc;
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 switch( msg )
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 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
2663 if(cinfo->combo)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2664 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
2665 else
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2666 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2667 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2668 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2669 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
2670 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2671 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2672 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2673 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2674 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2675 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
2676 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2677 if (!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2678 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2679 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
2680
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2681 /* 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
2682 * 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
2683 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2684 if (cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2685 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2686
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2687 if(msg == WM_KEYDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2688 SetTimer(hWnd, 101, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2689 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2690 KillTimer(hWnd, 101);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2691
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2692 return ret;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2695 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2696 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2697 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2698 if(mp1 == 101)
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(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2701 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2702 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
2703
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2704 /* 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
2705 * 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
2706 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2707 if(cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2708 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2709
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2710 return ret;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2713 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2714 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
2715 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
2716 if (ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2717 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2718 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
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 (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
2721 _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
2722 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
2723 _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
2724 else
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(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2726 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2727 else
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 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
2730 _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
2731 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
2732 _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
2733 else
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(hWnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2735 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2736 return FALSE;
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 else if(LOWORD(mp1) == '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2739 {
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2740
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2741 if ( cinfo->clickdefault )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2742 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2743 _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
2744 return (LRESULT)TRUE;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2745 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2746 else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2747 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2748 /*
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2749 * 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
2750 * has a default click set
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2751 */
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2752 HWND tl = _toplevel_window( hWnd );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2753 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA );
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2754 if ( mycinfo && mycinfo->clickdefault )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2755 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2756 _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
2757 return (LRESULT)TRUE;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2758 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2759 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2760 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2761
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2762 /* 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
2763 * 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
2764 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2765 if (cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2766 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
2767 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
2768 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2769 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2770 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2771 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2772 if(cinfo->buddy)
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 long val;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2775
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
2776 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
2777
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
2778 _sntprintf(tmpbuf, 99, TEXT("%ld"), val);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2779 SetWindowText(hWnd, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2780 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2781 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2782 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2783 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2784 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2785 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2786 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2787 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2788 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2789 case WM_CTLCOLORDLG:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2790 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2791 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
2792 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
2793 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2794 int thisback = thiscinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2795
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2796 /* Handle foreground */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2797 if(thiscinfo->fore != DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2798 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2799 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
2800
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2801 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
2802 DW_GREEN_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2803 DW_BLUE_VALUE(fore)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2804 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2805 /* Handle background */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2806 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
2807 {
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2808 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
2809
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2810 if(parentcinfo && parentcinfo->back != -1)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2811 thisback = parentcinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2812 }
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2813 if(thisback == DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2814 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2815 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2816
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2817 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
2818
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2819 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
2820 return (LONG)(intptr_t)hbr;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2821 }
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2822 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
2823 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2824 int back = _internal_color(thisback);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2825
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2826 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
2827 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2828 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2829 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2830 DeleteObject(thiscinfo->hbrush);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2831 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
2832 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2833 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2834 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
2835 return (LONG)(intptr_t)thiscinfo->hbrush;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2836 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2837 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2838 #ifdef AEROGLASS
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2839 switch(msg)
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2840 {
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2841 case WM_CTLCOLORSTATIC:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2842 case WM_CTLCOLORBTN:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2843 case WM_CTLCOLORDLG:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2844 {
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2845
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2846 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
2847 (!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
2848 {
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
2849 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
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 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
2852 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
2853 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
2854 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
2855 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
2856 return (LONG)thiscinfo->hbrush;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2857 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2858 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2859 }
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 #endif
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2862 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2863 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2864 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2865 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2866
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
2867 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
2868 {
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2869 if(!pOldProc)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2870 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
2871 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
2872 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2873 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
2874 }
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
2875
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2876 /* 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
2877 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
2878 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2879 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
2880
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2881 switch( msg )
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 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2884 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2885 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2886 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2887 break;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2888 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
2889 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
2890 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
2891 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
2892 int iItems, iTop, i;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2893 COLORREF c;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2894
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2895 /* 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
2896 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
2897 /* 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
2898 GetUpdateRect(hWnd, &rectUpd, FALSE);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2899 /* 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
2900 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
2901 /* number of displayed rows */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2902 iItems = ListView_GetCountPerPage(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2903 /* first visible row */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2904 iTop = ListView_GetTopIndex(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2905
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
2906 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
2907 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2908 /* 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
2909 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
2910 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2911 /* 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
2912 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
2913
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2914 if(c != DW_RGB_TRANSPARENT)
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 ListView_SetTextBkColor(hWnd, c);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2917 /* 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
2918 InvalidateRect(hWnd, &rectDestin, FALSE);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2919 /* ...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
2920 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
2921 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2922 }
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 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2926 case WM_LBUTTONDBLCLK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2927 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2928 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2929 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2930 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2931
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2932 if(LOWORD(mp1) == '\t')
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(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
2935 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2936 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2938 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2939 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2940
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2941 if(msg == WM_CHAR && (char)mp1 != '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2942 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2943
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2944 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2951 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2952
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2953 ListView_GetItem(hWnd, &lvi);
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
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 SignalHandler *tmp = Root;
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 while(tmp)
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 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
2962 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2963 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
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 /* 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
2966 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2967 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2968
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2969 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
2970 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2971 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2972 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2973 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2974 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2975 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2978 case WM_CONTEXTMENU:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2979 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2980 SignalHandler *tmp = Root;
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 while(tmp)
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 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
2985 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2986 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
2987 LONG x,y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2988 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2989 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2990 LVHITTESTINFO lhi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2991
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2992 dw_pointer_query_pos(&x, &y);
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 lhi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2995 lhi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2996
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2997 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
2998
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2999 iItem = ListView_HitTest(tmp->window, &lhi);
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3006 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3007
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3008 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3009 ListView_SetSelectionMark(tmp->window, iItem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3010 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3011
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3012 /* 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
3013 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3014 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3015
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3016 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
3017 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3018 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3019 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3020 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3021 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3022 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3023 break;
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
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3026 if(!continfo || !continfo->cinfo.pOldProc)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3027 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
3028 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
3031 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
3032 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3033 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
3034 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3035
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3036 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 switch( msg )
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 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
3041 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3042 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3043 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
3044 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
3045 if(ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3046 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3047 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
3048 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3049 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3051 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3052 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3053 break;
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
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3056 if(ret != TRUE)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3057 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3058 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
3059 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
3060 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
3061 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3062 return ret;
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3063 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3064
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3066 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3067 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3068
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3069 for(z=0;z<thisbox->count;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 if(thisbox->items[z].type == TYPEBOX)
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 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
3074 _changebox(tmp, percent, type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3075 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3076 else
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 if(type == DW_HORZ)
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(thisbox->items[z].hsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3081 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
3082 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3083 else
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 if(thisbox->items[z].vsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3086 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
3087 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3088 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3089 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3092 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
3093 {
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
3094 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
3095 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
3096
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 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
3098 ShowWindow(handle2, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3099
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3100 if(type == DW_HORZ)
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 int newx = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3103 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
3104 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
3105
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3106 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
3107
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3108 MoveWindow(handle1, 0, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3109 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3110
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3111 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
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 newx = x - newx - SPLITBAR_WIDTH;
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 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
3116 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3117
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3118 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
3119 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3120 else
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 int newy = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3123 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
3124 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
3125
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3126 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
3127
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3128 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
3129 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3130
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3131 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3132
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3133 newy = y - newy - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3134
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3135 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
3136 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3137
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3138 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
3139 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3140
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3141 ShowWindow(handle1, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3142 ShowWindow(handle2, SW_SHOW);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3143 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3144
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3145 /* 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
3146 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
3147 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3148 switch (msg)
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3149 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3150 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
3151 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
3152 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3153 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
3154 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
3155 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
3156 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
3157
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3158 /* 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
3159 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
3160 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
3161
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3162 /* 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
3163 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
3164 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
3165
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3166 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
3167 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3168 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
3169 si = &vsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3170 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3171
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3172 switch(which)
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 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
3175 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
3176 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3177 /*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
3178 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
3179 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
3180 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
3181 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
3182 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3183 /*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
3184 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
3185 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
3186 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
3187 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
3188 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3189 /*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
3190 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
3191 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
3192 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
3193 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
3194 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3195 /*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
3196 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
3197 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
3198 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
3199 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
3200 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3201 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3202
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3203 /* 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
3204 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
3205 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
3206 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
3207 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3208 break;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3209 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3210 return DefWindowProc(hwnd, msg, mp1, mp2);
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 /* 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
3214 LRESULT CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3216 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3217 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3218 case WM_ACTIVATE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3219 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3220 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3221
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3222 case WM_PAINT:
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 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3225 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
3226 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
3227 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
3228
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3229 BeginPaint(hwnd, &ps);
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 if((hdcPaint = GetDC(hwnd)) != NULL)
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 unsigned long cx, cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3234 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3235 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
3236
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3237 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
3238
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3239 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3240 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
3241 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3242 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
3243
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3244 SelectObject(hdcPaint, oldBrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3245 DeleteObject(SelectObject(hdcPaint, oldPen));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3246 ReleaseDC(hwnd, hdcPaint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3247 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3248 EndPaint(hwnd, &ps);
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3251 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3252 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3253 SetCapture(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3254 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3255 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3256 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3257 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3258 if(GetCapture() == hwnd)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3259 ReleaseCapture();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3260 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3261 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3262 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3263 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3264 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
3265 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
3266 int start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3267
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3268 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3269 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3270 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3271 SetCursor(LoadCursor(NULL, IDC_SIZENS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3272
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3273 if(GetCapture() == hwnd && percent)
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 POINT point;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3276 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3277 static POINT lastpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3278
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3279 GetCursorPos(&point);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3280 GetWindowRect(hwnd, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3281
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3282 if(memcmp(&point, &lastpoint, sizeof(POINT)))
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(PtInRect(&rect, 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 int width = (rect.right - rect.left);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3287 int height = (rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3288
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3289 if(type == DW_HORZ)
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 start = point.x - rect.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3292 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
3293 *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
3294 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3295 else
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 start = point.y - rect.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3298 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
3299 *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
3300 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3301 _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
3302 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3303 memcpy(&lastpoint, &point, sizeof(POINT));
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3306 break;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3309 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
3310 }
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
3311
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 /* 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
3313 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
3314 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3315 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3316 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3317 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3318 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3319 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3320 case WM_SETTEXT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3321 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3322 /* 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
3323 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
3324
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3325 InvalidateRgn(hwnd, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3326 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3327 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3328 case WM_PAINT:
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 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3331 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3332 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3333 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
3334 TCHAR tempbuf[1025] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3335 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3336 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
3337 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
3338
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3339 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
3340 GetWindowText(hwnd, tempbuf, 1024);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3341
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3342 hdcPaint = BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3343 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3344 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3345 rc.top = rc.left = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3346 rc.right = cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3347 rc.bottom = cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3348 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3349 if(hfont && oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3350 SelectObject(hdcPaint, oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3351 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3352 DeleteObject(hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3353 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3354 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3355 return FALSE;
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 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
3358 }
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
3359
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
3360 #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
3361 /* 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
3362 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
3363 {
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
3364 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
3365 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
3366
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 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
3368 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
3369
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
3370 /* 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
3371 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
3372
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
3373 /* 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
3374 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
3375 || !_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
3376 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
3377
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 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
3379
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 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
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 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
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 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
3385 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
3386
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 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
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 /* 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
3390 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
3391 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
3392 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
3393 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
3394 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
3395
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 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
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 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
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 /* 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
3401 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
3402
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 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
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 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
3406 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
3407 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
3408 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
3409 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
3410
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 /* 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
3412 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
3413 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
3414
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 /* 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
3416 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
3417 _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
3418
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 /* 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
3420 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
3421 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
3422 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
3423
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 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
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 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
3427 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
3428
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 /* 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
3430 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
3431 {
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 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
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 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
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 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
3437 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
3438 {
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 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
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 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
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 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
3444 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
3445 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
3446 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
3447 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
3448 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
3449 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
3450 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
3451 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
3452 }
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
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 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
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 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
3457 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
3458 }
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
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 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
3462 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
3463 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
3464 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
3465 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
3466 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
3467
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 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
3469 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
3470
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 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
3472 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
3473
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 /* 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
3475 _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
3476 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
3477 }
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 }
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 /* 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
3482 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
3483 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
3484 _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
3485 }
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 _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
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 }
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 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
3491 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
3492 }
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 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
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
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 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
3497 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
3498 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
3499 }
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 #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
3501
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
3502 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505
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
3506 LRESULT CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3508 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
3509 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
3510 int retval = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3511
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3512 if ( !cinfo )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3513 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3514
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3515 /* 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
3516 * window procedure because if a signal
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3517 * handler attached here destroys this
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3518 * window it will then be invalid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3519 */
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3520 pOldProc = cinfo->pOldProc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3521
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3522 switch(msg)
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 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3525 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3526 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3527 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3528 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3529 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3530 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
3531 return _colorwndproc(hwnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3532 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3533 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3534 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3535 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3536 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3537 SignalHandler *tmp = Root;
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3540 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3541 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3542 if(tmp->message == WM_COMMAND)
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 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
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 /* 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
3547 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3548 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3549 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
3550
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3551 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3552 in_checkbox_handler = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3553
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
3554 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3555
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3556 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3557 in_checkbox_handler = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3558 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3559 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3560 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3561 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3562 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3563 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3564 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3565 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3566 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3567 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3568 /* 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
3569 * 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
3570 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3571 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
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 SignalHandler *tmp = Root;
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3576 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3577 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3578 if(tmp->message == WM_COMMAND)
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 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
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 /* 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
3583 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3584 {
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
3585 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3586 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3587 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3588 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3589 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3590 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3591 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3592 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3593 if(LOWORD(mp1) == '\t')
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(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
3596 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3597 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3599 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3600 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3601 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3602 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3603 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3604 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
3605 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3606 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
3607 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3608 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3609 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3610
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
3611 /* 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
3612 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
3613 _dw_redraw(0, FALSE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3614 if ( !pOldProc )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3615 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3616 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
3617 }
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
3618
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 /* 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
3620 * 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
3621 */
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 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
3623 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3624 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3625 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
3626
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3627 if(array && array[pageid])
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 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
3630
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3631 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3632 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3633 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
3634 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
3635 if(box && box->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3636 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3637 ShowWindow(box->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3638 _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
3639 ShowWindow(box->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3640 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3641
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3642 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3643 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645
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
3646 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
3647 {
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
3648 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
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 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
3651 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
3652 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
3653
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 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
3655 if(text)
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3656 {
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3657 /* 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
3658 * 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
3659 */
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3660 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
3661 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
3662 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
3663
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3664 /* 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
3665 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
3666 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
3667 }
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
3668
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
3669 #ifndef GDIPLUS
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3670 /* 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
3671 */
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3672 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
3673 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3674 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
3675 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
3676
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3677 *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
3678 *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
3679
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3680 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
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 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
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
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3685 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
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 /* 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
3688 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
3689 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3690 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
3691 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
3692 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3693 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
3694 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
3695 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3696 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
3697 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3698 *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
3699 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
3700 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3701 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
3702 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3703 *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
3704 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
3705 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3706 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
3707 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3708 *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
3709 windowtype = BS_BITMAP;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3710 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3711 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
3712 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3713 else
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 /* 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
3716 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
3717 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
3718 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3719 *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
3720 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
3721 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3722 else
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 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
3725 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
3726 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
3727 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3728 *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
3729 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
3730 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3731 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3732 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
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 return windowtype;
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3735 }
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
3736 #endif
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3737
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3738 /* 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
3739 void _init_thread(void)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3740 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3741 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
3742 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
3743 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3744 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
3745 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
3746 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
3747
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3748 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
3749 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
3750 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
3751 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
3752 #endif
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(_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
3754 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
3755 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
3756 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3757 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3758
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3765 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3767 WNDCLASS wc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3768 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3769 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
3770 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
3771 #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
3772 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
3773 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3774
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3775 /* 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
3776 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
3777 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3778 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
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 /* 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
3781 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
3782 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
3783
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3784 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
3785 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
3786 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3787 /* 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
3788 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
3789 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
3790
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3791 /* Initialize our thread local storage */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3792 _foreground = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3793 _background = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3794 _hPen = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3795 _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
3796 #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
3797 _gpPen = TlsAlloc();
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3798 _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
3799 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3800
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3801 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3802 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
3803
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3804 InitCommonControlsEx(&icc);
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 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
3807
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3808 /* Register the generic Dynamic Windows class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3809 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3810 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3811 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3812 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3813 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3814 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3815 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3816 wc.lpszClassName = ClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3817
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3818 RegisterClass(&wc);
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 /* Register the splitbar control */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3821 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3822 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
3823 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3824 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3825 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3826 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3827 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3828 wc.lpszClassName = SplitbarClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3829
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3830 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3831
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3832 /* Register the scroller control */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3833 memset(&wc, 0, sizeof(WNDCLASS));
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3834 wc.style = CS_DBLCLKS;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3835 wc.lpfnWndProc = (WNDPROC)_scrollwndproc;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3836 wc.cbClsExtra = 0;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3837 wc.cbWndExtra = 32;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3838 wc.hbrBackground = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3839 wc.lpszMenuName = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3840 wc.lpszClassName = ScrollClassName;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3841
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3842 RegisterClass(&wc);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3843
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3844 /* 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
3845 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3846 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3847 wc.lpfnWndProc = (WNDPROC)_framewndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3848 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3849 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3850 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3851 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3852 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3853 wc.lpszClassName = FRAMECLASSNAME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3854
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3855 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3856
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
3857 /* 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
3858 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
3859 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
3860 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
3861 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
3862 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
3863 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
3864 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
3865 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
3866 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
3867
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 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
3869
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3870 #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
3871 /* Register HTML renderer class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3872 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3873 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3874 wc.lpszClassName = BrowserClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3875 wc.style = CS_HREDRAW|CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3876 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
3877 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3878
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3879 /* 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
3880 for(z=0;z<18;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3881 _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
3882
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3883 /* 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
3884 * 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
3885 * of Windows.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3886 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3887 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3888 wc.style = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3889 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3890 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3891 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3892 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3893 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3894 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3895 wc.lpszClassName = ObjectClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3896
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3897 RegisterClass(&wc);
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 /* 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
3900 * 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
3901 * 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
3902 * 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
3903 * packed into their correct parent.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3904 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3905
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
3906 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
3907 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3909 if(!DW_HWND_OBJECT)
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 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
3912 exit(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3913 }
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
3914
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
3915 /* 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
3916 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
3917 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
3918
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 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
3920
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
3921 /* 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
3922 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
3923
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3924 /* 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
3925 dwVersion = GetVersion();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3926 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3928 /* Initialize Security for named events and memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3929 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3930 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3931
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3932 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
3933
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3934 /*
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3935 * 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
3936 */
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3937 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
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 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
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 else
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3942 {
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
3943 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
3944 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3945
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3946 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3947 /* Setup GDI+ */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3948 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
3949 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
3950 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
3951 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
3952 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
3953 #endif
1628
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3954
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3955 /* 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
3956 _init_thread();
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3957
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3958 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
3959 _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
3960 #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
3961 /* 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
3962 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
3963 {
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3964 _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
3965 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
3966 _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
3967 _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
3968 _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
3969 _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
3970 _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
3971 _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
3972 _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
3973 }
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 /* 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
3975 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
3976 {
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 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
3978 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
3979 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3980 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3981 #ifdef RICHEDIT
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3982 /* 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
3983 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
3984 hrichedit = LoadLibrary("riched32");
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3985 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3986 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
3989 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
3990
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 * 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
3993 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3994 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3996 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3997
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3998 _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
3999 /* 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
4000 _dw_redraw(0, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4001
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4002 /* 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
4003 _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
4004
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4005 /* 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
4006 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
4007 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4008 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
4009 _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
4010 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4011 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4012 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4013 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4014 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4015 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4019 * 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
4020 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4021 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
4022 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4023 _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
4024 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4025
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4026 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4027 * 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
4028 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4029 * 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
4030 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4031 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
4032 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4033 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4034 double start = (double)clock();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4035
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4036 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
4037 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4038 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
4039 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4040 GetMessage(&msg, NULL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4041 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
4042 _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
4043 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4045 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4046 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4047 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4048 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4049 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4050 Sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4051 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4052 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4053
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4054 /*
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
4055 * 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
4056 */
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 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
4058 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4059 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4060
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4061 _dwtid = dw_thread_id();
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 if(GetMessage(&msg, NULL, 0, 0))
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(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4066 _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
4067 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4068 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4069 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4070 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4071 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4072 }
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
4073 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4074
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4081 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4083 free(ptr);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4091 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4093 DWDialog *tmp = malloc(sizeof(DWDialog));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4094
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4095 tmp->eve = dw_event_new();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4096 dw_event_reset(tmp->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4097 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4098 tmp->done = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4099 tmp->result = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4111 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4113 dialog->result = result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4114 dw_event_post(dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4115 dialog->done = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4116 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4125 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4127 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4128 void *tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4129
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4130 while (GetMessage(&msg,NULL,0,0))
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 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
4133 _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
4134 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4135 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4136 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4137 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4138 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4139 if(dialog->done)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4140 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4141 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4142 dw_event_close(&dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4143 tmp = dialog->result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4144 free(dialog);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4145 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 /*
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
4149 * 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
4150 * 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
4151 * 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
4152 * ...: 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
4153 */
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 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
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 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
4157 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
4158
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
4159 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
4160 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
4161 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
4162
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4163 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
4164 }
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
4165
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 389
diff changeset
4173 int API dw_messagebox(char *title, int flags, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4175 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
4176 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4177 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4178
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4179 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
4180 vsnprintf(outbuf, 1024, format, args);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4181 va_end(args);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4182
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4183 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
4184 if(rc == IDOK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4185 return DW_MB_RETURN_OK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4186 else if(rc == IDYES)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4187 return DW_MB_RETURN_YES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4188 else if(rc == IDNO)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4189 return DW_MB_RETURN_NO;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4190 else if(rc == IDCANCEL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4191 return DW_MB_RETURN_CANCEL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4192 else return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 /*
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
4196 * 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
4197 * 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
4198 * 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
4199 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4200 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
4201 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4202 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
4203 }
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
4204
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 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4206 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4207 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4208 * 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
4209 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4210 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
4211 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4212 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
4213 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4214
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 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4217 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4218 * 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
4219 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4220 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
4221 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4222 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
4223 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4224
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4225 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4230 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 {
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
4232 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
4233 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
4234
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 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
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 /* 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
4238 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
4239 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
4240
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 rc = ShowWindow(handle, SW_SHOW);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4242 SetFocus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4243 _initial_focus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4244 return rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4252 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4254 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4262 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 {
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4264 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
4265 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
4266
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4267 /* 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
4268 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
4269 {
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4270 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
4271 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
4272
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4273 _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
4274 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
4275
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4276 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
4277 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
4278 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
4279 }
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4280
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4281 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
4282 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
4283
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
4284 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
4285 _free_menu_data(menu);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4286
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
4287 /* 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
4288 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
4289 {
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
4290 dw_box_unpack(handle);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4291 _free_window_memory(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4292 EnumChildWindows(handle, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4293 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4294 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296
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
4297 /* 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
4298 * 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
4299 * 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
4300 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4301 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
4302 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4303 Box *mybox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4304
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4305 if(mybox)
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 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4308 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4309
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4310 GetClientRect(handle, &rect);
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 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
4313 _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
4314 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
4315 }
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
4316 }
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
4317
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4324 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4326 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
4327 }
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
4328
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4329 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
4330 {
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4331 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
4332 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
4333 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
4334
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4335 /* 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
4336 if(myFontName)
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4337 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
4338 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
4339 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
4340
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4341 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
4342 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
4343 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
4344 lf.lfWidth = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4345 lf.lfEscapement = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4346 lf.lfOrientation = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4347 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
4348 lf.lfUnderline = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4349 lf.lfStrikeOut = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4350 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
4351 lf.lfCharSet = DEFAULT_CHARSET;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4352 lf.lfOutPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4353 lf.lfClipPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4354 lf.lfQuality = DEFAULT_QUALITY;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4355 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
4356 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
4357 *Italic = 0;
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4358 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
4359 *Bold = 0;
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4360 _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
4361 free(myFontName);
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4362 return lf;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4363 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4364
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
4365 /* 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
4366 * 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
4367 */
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 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
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 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
4371 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
4372 }
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
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 /* 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
4375 * 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
4376 */
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4377 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
4378 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4379 HFONT hfont = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4380
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4381 if(fontname != DefaultFont && fontname[0])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4382 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4383 LOGFONT lf = _get_logfont(hdc, fontname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4384 hfont = CreateFontIndirect(&lf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4385 }
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
4386 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
4387 hfont = _DupFontHandle(_DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4388 if(!hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4389 hfont = GetStockObject(DEFAULT_GUI_FONT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4390 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4393 /* 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
4394 * 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
4395 */
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4396 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
4397 {
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4398 HDC hdc = GetDC(handle);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4399 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
4400 ReleaseDC(handle, hdc);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4401 return hfont;
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4402 }
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4403
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 /*
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
4405 * 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
4406 * 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
4407 * 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
4408 */
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 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
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 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
4412
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
4413 _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
4414 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
4415 {
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 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
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 }
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
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
4420 /* 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
4421 * 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
4422 */
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 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
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 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
4426 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
4427
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 /* 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
4429 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
4430 {
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(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
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 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
4434 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
4435
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 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
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 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
4439 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
4440 }
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 }
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 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
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
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 /* 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
4447 * 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
4448 *
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
4449 * 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
4450 * 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
4451 * 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
4452 * 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
4453 * 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
4454 * 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
4455 * 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
4456 */
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
4457 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
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 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
4460 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
4461 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
4462 HBITMAP hbm = 0;
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4463 HICON hic = 0;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4464 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
4465
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
4466 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
4467
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4468 /* 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
4469 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
4470 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
4471 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
4472 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
4473
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4474 /* 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
4475 if(hic)
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4476 {
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4477 if(GetIconInfo(hic, &ii))
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4478 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
4479 }
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4480
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4481 /* 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
4482 if(!hbm)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4483 {
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4484 /* 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
4485 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
4486 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
4487 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
4488 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
4489 }
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4490
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
4491 /* 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
4492 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
4493 {
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4494 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
4495
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4496 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
4497 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
4498 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
4499 }
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4500 else
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4501 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4502 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
4503
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4504 /* 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
4505 * 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
4506 */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4507 if(buf)
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 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
4511 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
4512 _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
4513 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
4514 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
4515 }
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4516 }
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
4517
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
4518 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4519 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
4520 {
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
4521 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
4522 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
4523 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
4524 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
4525 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
4526 }
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
4527 /* 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
4528 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
4529 _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
4530 _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
4531 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4532 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
4533 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
4534 {
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 /* 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
4536 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
4537 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
4538 }
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 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
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 /* 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
4542 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
4543 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
4544 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4545 }
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 /* Spinbuttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4547 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
4548 {
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
4549 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
4550 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
4551 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
4552 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4553 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4554 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4555 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
4556 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4557 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
4558 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
4559
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4560 if(imlist)
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4561 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
4562
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4563 /* 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
4564 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
4565 minsize = 20;
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4566 else
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4567 {
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4568 thiswidth += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4569 thisheight += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4570 }
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4571
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4572 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
4573 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
4574 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
4575 thisheight = minsize;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4576 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4577 #endif
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4578 /* Listbox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4579 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
4580 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4581 char buf[1025] = {0};
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4582 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
4583 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
4584
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4585 thisheight = 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 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
4588 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4589 int height, width = 0;
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 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
4592
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4593 if(strlen(buf))
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4594 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
4595 else
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, testtext, NULL, &height);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4597
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4598 width += basicwidth;
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 if(width > thiswidth)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4601 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
4602 thisheight += height;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4603 }
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4604
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4605 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
4606 thiswidth = _DW_SCROLLED_MIN_WIDTH;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4607 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
4608 thisheight = _DW_SCROLLED_MIN_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4609 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
4610 thisheight = _DW_SCROLLED_MAX_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4611 }
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
4612 /* 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
4613 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
4614 _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
4615 {
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
4616 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
4617 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
4618 {
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 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
4620 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
4621 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
4622 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
4623
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 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
4625 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
4626 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
4627 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
4628 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
4629
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 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
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 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
4633 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
4634 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
4635 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
4636
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
4637 /* MLE */
1581
a80ec948c3eb Fixed a MinGW warning and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1570
diff changeset
4638 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
4639 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4640 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
4641 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
4642 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
4643 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
4644 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
4645 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
4646
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 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
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 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
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 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
4652 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
4653 }
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 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
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 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
4657 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
4658 }
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 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
4660 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
4661 }
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
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 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
4664 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
4665 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
4666 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
4667 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
4668 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
4669 }
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
4670 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
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 /* 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
4673 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
4674 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
4675 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
4676 }
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 }
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4678 /* Container */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4679 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
4680 {
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4681 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
4682
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4683 thiswidth = LOWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4684 thisheight = HIWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4685
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4686 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
4687 thiswidth = _DW_SCROLLED_MAX_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4688 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
4689 thiswidth = _DW_SCROLLED_MIN_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4690 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
4691 thisheight = _DW_SCROLLED_MIN_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4692 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
4693 thisheight = _DW_SCROLLED_MAX_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4694 }
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4695 /* Tree */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4696 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
4697 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
4698 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
4699 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
4700 }
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
4701 /* Buttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4702 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
4703 {
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
4704 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
4705
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
4706 /* 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
4707 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
4708 {
1431
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4709 extrawidth = 5;
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4710 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
4711 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4712 /* 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
4713 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
4714 {
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
4715 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
4716 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
4717 }
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
4718 /* 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
4719 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
4720 {
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 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
4722 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
4723 }
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
4724 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4725 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
4726 {
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
4727 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
4728 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
4729 }
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
4730
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
4731 /* 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
4732 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
4733 *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
4734 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
4735 *height = thisheight + extraheight;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4736
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4737 /* Free temporary bitmaps */
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4738 if(ii.hbmColor)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4739 DeleteObject(ii.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4740 if(ii.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4741 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
4742 }
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
4743
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
4744 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4750 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 {
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4752 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
4753 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
4754 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
4755
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4756 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
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 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
4759 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
4760 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4761 /* groupbox */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4762 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
4763 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
4764 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4765 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
4766 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4767 }
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4768
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4769 /* 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
4770 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
4771 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
4772
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
4773 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
4774 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4775 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
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 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
4778 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
4779 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
4780 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
4781 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4782 else
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 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
4785 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
4786
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
4787 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
4788
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4789 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
4790 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
4791 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4792 }
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
4793 /* 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
4794 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
4795 {
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 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
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 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
4799 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
4800 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
4801
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 /* 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
4803 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
4804 {
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
4805 _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
4806 /* 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
4807 _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
4808 }
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
4809 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
4810 }
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_UNKNOWN;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4814 /* 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
4815 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4816 * currfont: current font
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4817 * Returns:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4818 * 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
4819 */
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4820 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
4821 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4822 CHOOSEFONT cf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4823 LOGFONT lf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4824 char *str = NULL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4825 char *bold = "";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4826 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
4827
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4828 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
4829 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
4830
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4831 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
4832 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
4833 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
4834
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4835 if(ChooseFont(&cf))
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4836 {
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
4837 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
4838 if ( str )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4839 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4840 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
4841 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
4842
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4843 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
4844 bold = " Bold";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4845 if ( lf.lfItalic )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4846 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
4847 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
4848 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
4849 _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
4850 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4851 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4852 return str;
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 /*
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4856 * 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
4857 * Parameters:
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4858 * handle: The window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4859 * 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
4860 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4861 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
4862 {
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4863 HFONT oldfont = NULL;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4864 char *str = NULL;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4865 char *bold = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4866 char *italic = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4867 LOGFONT lf = { 0 };
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4868 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
4869 TCHAR tmpbuf[100] = {0};
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4870
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4871 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
4872 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
4873 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4874 /* groupbox */
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4875 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
4876 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
4877 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4878 handle = thisbox->grouphwnd;
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 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4881 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
4882 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
4883 {
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
4884 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
4885 if ( str )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4886 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4887 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
4888 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
4889
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4890 if ( lf.lfWeight > FW_MEDIUM )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4891 bold = " Bold";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4892 if ( lf.lfItalic )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4893 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
4894 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
4895 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
4896 _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
4897 }
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4898 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4899 if ( oldfont )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4900 DeleteObject( oldfont );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4901 return str;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4902 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4903
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4904 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907 * 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
4908 * 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
4909 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4911 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4913 ColorInfo *cinfo;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4914 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
4915 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4916
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4917 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4920
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4921 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
4922 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
4923 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
4924 cinfo->back = back = _internal_color(back);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4926 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
4927 DW_GREEN_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4928 DW_BLUE_VALUE(fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4929 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
4930 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4931 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4932 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
4933 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4934 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4935 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4936 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4937 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4938 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
4939 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4940 /* groupbox */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4941 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
4942 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
4943 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4944 thisbox->cinfo.fore = fore;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4945 thisbox->cinfo.back = back;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4946 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4947 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4949 if(cinfo)
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 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4952 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4953 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4954 else
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 cinfo = calloc(1, sizeof(ColorInfo));
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->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4959 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4960
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4961 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4962 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4963 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4964 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4965 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4974 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4976 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4984 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4986 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4992 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4994 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4998 * 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
4999 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5000 * 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
5001 * 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
5002 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
5003 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
5004 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5005 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
5006
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5007 if(!pointertype)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5008 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
5009 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5010 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5011 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
5012 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5013 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5014 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5015
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5016 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 * 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
5021 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5023 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5025 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5026 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
5027 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
5028 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5029 MARGINS mar = {-1};
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5030
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5031 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
5032 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
5033 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5034
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5035 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
5036 newbox->vsize = newbox->hsize = SIZEEXPAND;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5037 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5038
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5039 if(!(flStyle & WS_CAPTION))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5040 flStyle |= WS_POPUPWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5041
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5042 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
5043 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
5044 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5045 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
5046 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5047 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5048 else
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 flStyleEx |= WS_EX_TOOLWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5051
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5052 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
5053 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5054 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5055 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
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 if(hwndOwner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5058 SetParent(hwndframe, hwndOwner);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5059
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5060 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5061 /* 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
5062 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
5063 {
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5064 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
5065 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5066 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5067 #endif
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5068
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5069 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 * 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
5075 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5078 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5080 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5081 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5082
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5083 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5084 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5085 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5086 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5087 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5088
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5089 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5090 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5091 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
5092 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5093 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5094 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5095 DWInstance,
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5098 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5099 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5100
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5101 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5102 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5106 * 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
5107 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5108 * 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
5109 * 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
5110 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5111 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
5112 {
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5113 ColorInfo *cinfo = calloc(sizeof(ColorInfo), 1);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5114 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
5115 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
5116 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
5117
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5118 cinfo->fore = cinfo->back = -1;
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 hwndframe = CreateWindow(ScrollClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5121 NULL,
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5122 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
5123 0,0,0,0,
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5124 DW_HWND_OBJECT,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5125 NULL,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5126 DWInstance,
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
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5129 cinfo->buddy = box;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5130 cinfo->combo = tmpbox;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5131 SetParent(tmpbox, hwndframe);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5132 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)cinfo);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5133 return hwndframe;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5134 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5135
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5136 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5137 * 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
5138 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5139 * 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
5140 * 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
5141 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5142 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
5143 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5144 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
5145 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
5146
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5147 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
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 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
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
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5152 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
5153 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
5154
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5155 /* 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
5156 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
5157 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5158 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
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 si.nPos;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5161 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5162
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5163 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5164 * 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
5165 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5166 * 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
5167 * 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
5168 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5169 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
5170 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5171 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
5172 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
5173
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5174 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
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 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
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
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5179 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
5180 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
5181
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5182 /* 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
5183 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
5184 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5185 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
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 si.nMax;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5188 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5189 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 * 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
5192 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5196 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5198 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5199 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5201 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5202 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5203 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5204 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5205
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5206 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5207 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5208 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
5209 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5210 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5211 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5212 DWInstance,
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
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5215 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5216 UTF8toWide(title),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5217 WS_CHILD | BS_GROUPBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5218 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
5219 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5220 hwndframe,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5221 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5222 DWInstance,
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5225 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
5226 dw_window_set_font(hwndframe, DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5227 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5231 * 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
5232 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5233 * 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
5234 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5235 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
5236 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5237 CLIENTCREATESTRUCT ccs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5238 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5239
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5240 ccs.hWindowMenu = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5241 ccs.idFirstChild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5242
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5243 hwndframe = CreateWindow(TEXT("MDICLIENT"),
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5244 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5245 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
5246 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5247 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
5248 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5249 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5250 &ccs);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5251 return hwndframe;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5252 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5253
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5254 /*
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5255 * 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
5256 * Parameters:
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5257 * 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
5258 */
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5259 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
5260 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5261 #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
5262 return CreateWindow(BrowserClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5263 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5264 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
5265 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5266 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
5267 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5268 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5269 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
5270 #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
5271 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
5272 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
5273 #endif
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5274 }
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5275
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5276 #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
5277 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
5278 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
5279 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
5280 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5281
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5282 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5283 * 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
5284 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5285 * 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
5286 * 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
5287 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5288 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
5289 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5290 #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
5291 _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
5292 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5293 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5294
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 * 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
5297 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5298 * 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
5299 * 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
5300 * be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5301 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5302 * 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
5303 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5304 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
5305 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5306 #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
5307 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
5308 #else
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_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5310 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5311 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5312
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 * 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
5315 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5316 * 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
5317 * 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
5318 * 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
5319 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5320 * 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
5321 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5322 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
5323 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5324 #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
5325 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
5326 #else
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_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5328 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5329 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5330
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5331 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 * 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
5334 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5336 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5338 return CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5339 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
5340 SS_BITMAP | SS_CENTERIMAGE | WS_VISIBLE |
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5341 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
5342 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5343 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
5344 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5345 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5346 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5355 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5357 ULONG flags = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5358 HWND tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5359 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
5360 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5361
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5362 if(!top)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5363 flags = TCS_BOTTOM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5364
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5365 tmp = CreateWindow(WC_TABCONTROL,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5366 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5367 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
5368 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5369 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
5370 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5371 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5372 NULL);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5373 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
5374 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
5375 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
5376 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
5377 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5378 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5387 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5389 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5397 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5399 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
5400 MENUINFO mi;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5401
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5402 tmp = (HMENUI)CreateMenu();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5403
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
5404 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
5405 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
5406 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
5407
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 SetMenuInfo( (HMENU)tmp, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5409
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5410 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
5411
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5412 SetMenu(location, (HMENU)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5413 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5421 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5423 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5424 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5425 HMENU mymenu = (HMENU)*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 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5428 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
5429 if(IsMenu(mymenu))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5430 DestroyMenu(mymenu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5431 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433
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
5434 /* 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
5435 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
5436 {
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
5437 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
5438
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
5439 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
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 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
5442 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
5443 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
5444 }
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 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
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5451 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 * 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
5456 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5459 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
5460 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5461 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5462 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
5463 char buffer[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5464 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
5465 char *menutitle = title;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5466
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5467 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5468 * 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
5469 * for the menubar
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5470 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5471 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5472 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
5473
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5474 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5475 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5476 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
5477
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5478 /* 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
5479 if (title)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5480 {
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
5481 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
5482
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 strcpy(tmp, title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5484
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5485 while(*tmp)
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 if(*tmp == '~')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5488 *tmp = '&';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5489 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5490 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5491 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5492
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
5493 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
5494 {
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
5495 /* 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
5496 * 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
5497 */
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 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
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 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
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 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
5503 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
5504
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 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
5506 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
5507 }
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 /* 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
5509 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
5510 {
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 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
5512
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
5513 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
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 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
5516 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
5517 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
5518 }
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 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
5520 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
5521 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5522 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
5523 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5524 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5525 mii.fType = MFT_SEPARATOR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5526
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5527 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5528 * Handle flags
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 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
5531 if ( is_checked )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5532 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5533 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5534 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5535 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
5536 if ( is_disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5537 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5538 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5539 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5541 mii.wID = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5542 if (IsMenu((HMENU)submenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5543 mii.hSubMenu = (HMENU)submenu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5544 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5545 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
5546 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
5547 mii.cch = (UINT)_tcslen(mii.dwTypeData);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5548
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5549 InsertMenuItem(mymenu, 65535, TRUE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5550
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
5551 _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
5552 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
5553 _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
5554 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
5555 _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
5556 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
5557 _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
5558 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
5559
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
5560 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
5561 {
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 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
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 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
5565 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
5566 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
5567
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 SetMenuInfo( (HMENU)submenu, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5569 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5570
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5571 if (IsWindow(menux) && !IsMenu((HMENU)menux))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5572 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
5573 return (HWND)(uintptr_t)id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 * 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
5578 * Deprecated: use dw_menu_item_set_state()
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5580 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5584 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5586 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
5587 HMENU mymenu = (HMENU)menux;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5588 char buffer[30];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5589
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5590 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5591 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
5592
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5593 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5594 * 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
5595 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5596 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5597 GetMenuItemInfo( mymenu, id, FALSE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5598
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5599 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5600 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5601 if (check)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5602 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5603 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5604 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5605 SetMenuItemInfo( mymenu, id, FALSE, &mii );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5606 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5607 * Keep our internal state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5608 */
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
5609 _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
5610 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
5611 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5612
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 * Sets the state of a menu item.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5615 * Parameters:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5616 * menu: The handle to the existing menu.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5617 * id: Menuitem id.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5618 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5619 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5620 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5621 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
5622 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5623 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5624 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
5625 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
5626 int check;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5627 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
5628
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5629 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
5630 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
5631
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
5632 _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
5633 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
5634 _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
5635 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
5636
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5637 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5638
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5639 mii.cbSize = sizeof(MENUITEMINFO);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5640 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5641 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
5642 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5643 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5644 * 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
5645 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5646 if ( state & DW_MIS_CHECKED )
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 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5649 check = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5650 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5651 else
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 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5654 check = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5655 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5656 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5657 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5658 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5659 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5660 * ...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
5661 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5662 if ( check )
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 mii.fState |= MFS_CHECKED;
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 else
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 mii.fState |= MFS_UNCHECKED;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5671 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
5672 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5673 if ( 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 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5676 disabled = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5677 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5678 else
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 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5681 disabled = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5682 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5683 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5684 else
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 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5687 * ...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
5688 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5689 if ( disabled )
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 mii.fState |= MFS_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 else
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 mii.fState |= MFS_ENABLED;
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 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5698 SetMenuItemInfo( mymenu, id, FALSE, &mii );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5699 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5700 * Keep our internal checked state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5701 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5702 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
5703 dw_window_set_data( DW_HWND_OBJECT, buffer2, DW_INT_TO_POINTER(disabled) );
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5706 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5707 * Deletes the menu item specified
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5708 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5709 * 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
5710 * 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
5711 * Returns:
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5712 * 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
5713 */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5714 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
5715 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5716 HMENU mymenu = (HMENU)menux;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5717
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5718 if ( IsWindow(menux) && !IsMenu(mymenu) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5719 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
5720
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
5721 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
5722 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
5723
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
5724 /* 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
5725 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
5726 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
5727
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
5728 /* 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
5729 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
5730 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
5731 return DW_ERROR_NONE;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5732 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5733
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5742 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5744 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5745 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5746 HMENU mymenu = (HMENU)*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 if(IsWindow(*menu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5749 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
5750
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5751 popup = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5752 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
5753 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
5754 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756
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 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5764 HWND API dw_container_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5766 HWND tmp = CreateWindow(WC_LISTVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5767 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5768 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5769 (multi ? 0 : LVS_SINGLESEL) |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5770 LVS_REPORT | LVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5771 LVS_SHAREIMAGELISTS | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5772 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
5773 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5774 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
5775 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5776 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5777 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5778 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5779
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5780 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5783 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5784 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5785
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5786 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5787 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
5788 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
5789
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5790 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5791 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
5792 /* 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
5793 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
5794 {
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 /* 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
5796 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
5797 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5798 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5802 * 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
5803 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5804 * 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
5805 * 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
5806 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5807 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
5808 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5809 HWND tmp = CreateWindow(WC_TREEVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5810 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5811 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5812 TVS_HASLINES | TVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5813 TVS_HASBUTTONS | TVS_LINESATROOT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5814 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
5815 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5816 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
5817 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5818 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5819 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5820 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5821 TreeView_SetItemHeight(tmp, 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5822
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5823 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5826 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5827 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5828
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5829 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5830 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
5831 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
5832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5833 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5834 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5835 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
5836 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5837
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5838 /*
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
5839 * 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
5840 * 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
5841 * 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
5842 * 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
5843 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5844 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
5845 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5846 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5847
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5848 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5849 if(x && y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5850 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5851 *x = ptl.x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5852 *y = ptl.y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5853 }
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
5854 }
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
5855
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 * 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
5858 * 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
5859 * 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
5860 * 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
5861 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5862 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
5863 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5864 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
5865 }
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
5866
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 * 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
5871 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5873 HWND API dw_text_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5875 HWND tmp = CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5876 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
5877 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
5878 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
5879 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5880 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
5881 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5882 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5883 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
5884 #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
5885 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
5886
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 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
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->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
5890 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
5891 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5892 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
5893 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
5894 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5898 * 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
5899 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5900 * 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
5901 * 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
5902 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5903 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
5904 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5905 HWND tmp = CreateWindow(StatusbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5906 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
5907 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
5908 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5909 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
5910 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5911 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5912 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5913 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5914 return tmp;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5915 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5916
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5917 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 * 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
5920 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5922 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 {
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
5924
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5925 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
5926 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5927 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5928 WS_VISIBLE | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5929 WS_VSCROLL | ES_MULTILINE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5930 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5931 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
5932 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5933 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
5934 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5935 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5936 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5937 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5938
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5939 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5942 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5943 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5944
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5945 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5946 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
5947 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
5948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5949 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5950 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5951 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 * 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
5958 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5960 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5962 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
5963 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5964 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5965 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5966 WS_BORDER | ES_AUTOHSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5967 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
5968 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5969 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
5970 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5971 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5972 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5973 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5974
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5975 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5978 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5979 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5980 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 /*
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
5984 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 * 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
5987 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5989 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5991 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
5992 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5993 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5994 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5995 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5996 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
5997 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5998 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
5999 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6000 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6001 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6002 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6003
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6004 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6007 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6008 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6009 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011
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
6012 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
6013 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6014 ColorInfo *cinfo = (ColorInfo *)lp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6015
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6016 if(cinfo)
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 cinfo->buddy = handle;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6019 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6020 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6021 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6022 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
6023 }
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
6024
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 * 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
6029 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6031 HWND API dw_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6033 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6034 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6035 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6036 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
6037 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6038 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
6039 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6040 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6041 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6042 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6043 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6044
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6045 if(!cinfo || !cinfo2)
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)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6048 free(cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6049 if(cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6050 free(cinfo2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6051 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6052 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6053 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6054
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6055 cinfo2->fore = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6056 cinfo2->back = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6057 cinfo2->combo = cinfo->combo = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6058 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
6059 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
6060
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6061 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6062 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
6063 SetWindowText(tmp, UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6064 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 * 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
6071 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6073 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6075 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
6076
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6077 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6078 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
6079 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
6080 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
6081 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
6082 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
6083 (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
6084 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6085 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6086 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6087 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
6088
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6089 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
6090 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
6091 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6094 #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
6095 /* 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
6096 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
6097 {
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 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
6099 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
6100 {
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 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
6102 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
6103
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 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
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(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
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 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
6109 /* 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
6110 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
6111
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 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
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 }
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 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
6116 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
6117 }
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 }
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
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6120 /* 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
6121 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
6122 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6123 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
6124 HIMAGELIST imlist, dimlist;
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6125 BITMAP bmi = { 0 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6126 TBBUTTON tbButtons[] = {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6127 { 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
6128 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6129
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6130 /* 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
6131 if(hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6132 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6133 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
6134 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
6135 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
6136 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
6137 _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
6138 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
6139 DeleteObject(hbitmap);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6140 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6141 else if(icon)
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 ICONINFO iconinfo;
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 GetIconInfo(icon, &iconinfo);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6146 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
6147 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
6148 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
6149 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
6150 _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
6151 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
6152 DeleteObject(iconinfo.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6153 DeleteObject(iconinfo.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6154 DestroyIcon(icon);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6155 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6156 else
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6157 return 0;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6158
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6159 /* Create the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6160 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
6161 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
6162
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
6163 /* 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
6164 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
6165 _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
6166
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6167 /* 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
6168 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
6169 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
6170 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
6171 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
6172 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
6173 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
6174
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6175 _create_tooltip(tmp, text);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6176 return tmp;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6177 }
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6178 #endif
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6179
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6186 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6188 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6189 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
6190 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
6191 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
6192 #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
6193 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
6194 {
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 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
6196 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
6197 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
6198 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
6199 }
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 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6201
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6202 tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6203 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6204 WS_CHILD | BS_PUSHBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6205 WS_VISIBLE | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6206 (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
6207 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6208 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
6209 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6210 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6211 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6212
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6213 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6214 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
6215
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6216 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
6217
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
6218 _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
6219
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6220 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6221 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6222 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
6223 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6224 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6225 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6226 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
6227 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6228 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6232 * 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
6233 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6234 * 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
6235 * 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
6236 * 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
6237 * DW pick the appropriate file extension.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6238 * (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
6239 */
507
c607eb385e58 Added missing calling conventions. Thanks Bastian for pointing this out.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 506
diff changeset
6240 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
6241 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6242 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6243 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6244 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
6245 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
6246 int windowtype = 0;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6247
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6248 if (!cinfo)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6249 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6250
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
6251 #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
6252 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
6253 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
6254 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
6255 {
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 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
6257 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
6258 }
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
6259 #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
6260 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
6261 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6262
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6263 #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
6264 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
6265 {
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 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
6267 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
6268 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
6269 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
6270 }
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 #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
6272 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6273 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
6274 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
6275 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
6276 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
6277 (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
6278 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6279 NULL);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6280
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6281 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6282 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
6283
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6284 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6285
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
6286 _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
6287
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
6288 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
6289 {
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 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
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 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
6293 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6294 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6295 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6296 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
6297 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6298
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 * 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
6301 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6302 * 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
6303 * 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
6304 * 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
6305 * (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
6306 * 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
6307 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6308 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
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 tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6311 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
6312 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
6313 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
6314 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
6315 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
6316 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
6317
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6318 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
6319 return 0;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6320
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6321 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
6322 if ( file != NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6323 {
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 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
6325 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
6326 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6327 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
6328 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
6329 #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
6330 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
6331 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
6332 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
6333 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
6334 #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
6335 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
6336 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
6337 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
6338 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6339 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
6340 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
6341 }
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
6342 #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
6343 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6344 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6345 {
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
6346 _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
6347 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
6348 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
6349 }
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
6350 _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
6351 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
6352 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6353
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6354 #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
6355 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
6356 {
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 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
6358 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
6359 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
6360 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
6361 }
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 #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
6363 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6364 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
6365 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
6366 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
6367 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
6368 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
6369 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
6370 (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
6371 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6372 NULL );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6373
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6374 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6375 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
6376
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6377 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
6378
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
6379 _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
6380
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
6381 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
6382 {
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 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
6384 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6385 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
6386 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6387 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6388 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6389 return tmp;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6390 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6391
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6392 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 * 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
6396 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6398 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6400 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
6401 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6402 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6403 WS_CHILD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6404 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
6405 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6406 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6407 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6408 DWInstance,
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 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6411 UPDOWN_CLASS,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6412 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6413 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6414 UDS_ARROWKEYS | UDS_SETBUDDYINT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6415 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
6416 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6417 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
6418 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6419 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6420 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6421 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6422
1025
3573878d1239 Make sure the initial spinbutton limits on Windows match the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1006
diff changeset
6423 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
6424 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6425 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6426 cinfo->buddy = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6427
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6428 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6429 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6430
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6431 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6432 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
6433 /* 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
6434 * 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
6435 * 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
6436 */
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6437 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
6438 {
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6439 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
6440 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6441
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6442 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6443 dw_window_set_font(buddy, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6444 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 * 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
6451 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6453 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6455 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6456 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6457 WS_CHILD | BS_AUTORADIOBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6458 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
6459 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6460 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
6461 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6462 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6463 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6464 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
6465 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6466 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
6467 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
6468 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
6469 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
6470 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
6471 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6472
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 * 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
6476 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6477 * 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
6478 * 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
6479 * 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
6480 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6481 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
6482 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6483 HWND tmp = CreateWindow(TRACKBAR_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6484 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6485 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6486 (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
6487 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6488 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
6489 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6490 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6491 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6492 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6493
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6494 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6497 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
6498 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
6499 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6503 * 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
6504 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6505 * 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
6506 * 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
6507 * 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
6508 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
6509 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
6510 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6511 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6512 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6513 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6514 (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
6515 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6516 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
6517 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6518 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6519 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6520 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6521
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6522 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6525 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6526 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
6527 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
6528 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6529
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6530 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
6531 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532 * 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
6533 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6535 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6537 return CreateWindow(PROGRESS_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6538 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6539 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
6540 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6541 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
6542 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6543 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6544 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 * 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
6551 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6553 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6555 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
6556 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6557 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6558 WS_CHILD | BS_AUTOCHECKBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6559 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
6560 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6561 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
6562 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6563 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6564 NULL);
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6565 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
6566 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
6567 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
6568 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
6569 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
6570 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575 * 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
6576 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6579 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6581 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6582 LISTBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6583 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6584 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6585 WS_CHILD | LBS_HASSTRINGS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6586 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6587 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
6588 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6589 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
6590 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6591 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6592 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6593 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6594
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6595 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6598 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6599 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6600
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6601 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
6602 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
6603 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6604
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6605 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6606 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6607 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6608 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 */
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
6616 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
6617 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6618 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
6619 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
6620
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6621 SendMessage(handle, WM_SETICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6622 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6623 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6624 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6625
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
6626 /* 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
6627 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
6628 {
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 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
6630 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
6631 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
6632
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 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
6634 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
6635
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 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
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 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
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 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
6641 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
6642 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
6643 (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
6644 (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
6645 }
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 #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
6647 /* 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
6648 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
6649 {
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 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
6651 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
6652 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
6653
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 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
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 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
6657 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
6658 _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
6659 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
6660 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
6661 }
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 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
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 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
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 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
6667 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
6668 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
6669 _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
6670 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
6671 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
6672 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
6673 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
6674 }
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
6675 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
6676 }
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
6677 #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
6678 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
6679 {
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 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
6681 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
6682 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
6683 (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
6684 (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
6685 }
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
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 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
6688 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
6689 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
6690 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
6691
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 /* 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
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 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
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 /* 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
6697 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
6698 {
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 _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
6700 /* 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
6701 _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
6702 }
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 }
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 * 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
6710 * 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
6711 * (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
6712 * 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
6713 * 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
6714 * 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
6715 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6716 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
6717 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6718 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
6719 HANDLE icon = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6720
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6721 if(id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6722 {
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
6723 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
6724 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
6725 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6726 else if(filename)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6727 {
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
6728 #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
6729 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
6730 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6731 _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
6732 #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
6733 }
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
6734
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 _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
6736 }
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6737
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6738 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6739 * 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
6740 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6741 * 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
6742 * 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
6743 * (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
6744 * 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
6745 * 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
6746 * 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
6747 * 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
6748 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6749 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
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 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
6752 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
6753 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
6754 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
6755
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6756 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
6757 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6758 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
6759 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
6760 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6761 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
6762 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
6763 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6764 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
6765 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
6766 #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
6767 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
6768 #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
6769 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
6770 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
6771 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
6772 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
6773 #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
6774 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6775 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6776 {
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
6777 _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
6778 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
6779 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6780 }
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
6781 _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
6782 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
6783 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6784 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
6785 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6786 }
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6787 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
6788 {
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6789 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
6790 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
6791 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6792
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
6793 _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
6794 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6795
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6797 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6798 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6803 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6805 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
6806 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
6807
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6808 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6809
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6810 SetWindowText(handle, wtext);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6811
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6812 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6813 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
6814 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
6815 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
6816 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6817 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
6818 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
6819 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
6820 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6821 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
6822 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6823 /* groupbox */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6824 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6825 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
6826 SetWindowText( thisbox->grouphwnd, wtext );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6827 }
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
6828 /* 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
6829 {
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 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
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 /* 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
6833 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
6834 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6835 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
6836
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6837 _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
6838
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6839 /* 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
6840 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
6841 (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
6842 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6843 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
6844 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
6845 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
6846 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
6847 /* 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
6848 _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
6849 }
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
6850 }
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
6851 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6852 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6854 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6855 * 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
6856 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6857 * 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
6858 * 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
6859 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6860 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
6861 {
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
6862 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
6863
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 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
6865 _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
6866 _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
6867 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6868
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6869 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6870 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6876 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6878 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
6879 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
6880 int len;
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6881
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6882 GetClassName(handle, tmpbuf, 99);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6883
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6884 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
6885 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6886 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
6887
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6888 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
6889 handle = cinfo->buddy;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6890 else
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6891 return NULL;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6892 }
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6893
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6894 /* 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
6895 * and fill it with the current text.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6896 */
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
6897 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
6898 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
6899 GetWindowText(handle, tempbuf, len);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6900
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6901 /* 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
6902 * 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
6903 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6904 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
6905 retbuf = _strdup(retbuf);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6906 return retbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6907 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6908
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6914 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 {
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
6916 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
6917 {
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
6918 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
6919 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
6920 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
6921
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
6922 _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
6923 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
6924
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 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
6926 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
6927 }
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 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
6929 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6937 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 {
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
6939 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
6940 {
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
6941 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
6942 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
6943 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
6944
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
6945 _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
6946 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
6947
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 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
6949 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
6950 }
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 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6952 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6954
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6955 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6956
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6957 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
6958 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6959 if(GetWindowLong(handle, GWL_ID) == lParam)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6960 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6961 _dw_wfid_hwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6962 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6963 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6964 return TRUE;
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6965 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6966
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6973 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6975 _dw_wfid_hwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6976 EnumChildWindows(handle, _wfid, (LPARAM)id);
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6977 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
6978 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
6979
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6980 /* 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
6981 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
6982 {
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
6983 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
6984 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
6985
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
6986 /*
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 * 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
6988 * 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
6989 */
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 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
6991 {
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6992 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
6993 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
6994 }
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
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 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
6997
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
6998 /* 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
6999 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
7000 {
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
7001 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
7002 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
7003 {
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 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
7005 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
7006 }
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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7008 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
7009 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
7010 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
7011 {
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 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
7013 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
7014
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
7015 /* 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
7016 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
7017 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
7018 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
7019 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
7020 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
7021 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
7022
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7023 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
7024
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
7025 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
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 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
7028 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
7029 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
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 }
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
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 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
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 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
7036 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
7037 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
7038 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
7039
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7040 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
7041 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
7042 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
7043 {
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
7044 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
7045 {
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
7046 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
7047 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
7048 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
7049 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
7050 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
7051 }
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 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
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 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
7055 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
7056 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
7057 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
7058
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 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
7060 }
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
7061 }
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
7062
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 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
7064 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
7065 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
7066 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
7067 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
7068 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
7069
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 /* 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
7071 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
7072 _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
7073
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
7074 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
7075
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7076 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
7077 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
7078
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 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
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 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
7082 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
7083 {
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
7084 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
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 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
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 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
7089 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
7090 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
7091 }
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 }
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7093 #ifdef TOOLBAR
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7094 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
7095 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7096 #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
7097 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
7098 #endif
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7099 {
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7100 /* 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
7101 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
7102 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7103 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7104 #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
7105 /* 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
7106 _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
7107 }
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
7108 }
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 /*
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7111 * 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
7112 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7113 * 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
7114 * Returns:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7115 * 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
7116 */
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
7117 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
7118 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7119 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
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 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
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 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
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 /* 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
7126 * 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
7127 */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7128 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
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 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
7131 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
7132
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7133 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
7134 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
7135
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7136 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
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 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
7139 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
7140 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7141
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7142 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
7143 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
7144
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7145 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
7146 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7147 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
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 /* 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
7150 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
7151 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7152 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
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 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
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 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
7157 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7158 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7159
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7160 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
7161 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
7162 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
7163 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
7164 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
7165 else
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 = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7167
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7168 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
7169 /* 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
7170 _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
7171 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
7172 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7173 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7174 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
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
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 * 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
7179 * Parameters:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7180 * 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
7181 * 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
7182 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7183 * 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
7184 */
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
7185 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
7186 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7187 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
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 /* 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
7190 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
7191 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7192 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
7193 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
7194 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
7195
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7196 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
7197 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7198 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
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 /* 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
7201 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
7202 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7203 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
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 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
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 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
7208 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7209 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7210
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7211 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
7212 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
7213 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
7214 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
7215 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
7216 else
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 = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7218
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7219 /* 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
7220 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
7221 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
7222 /* 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
7223 _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
7224 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
7225 }
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 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
7227 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7228
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7229 /*
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7230 * 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
7231 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7232 * 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
7233 * 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
7234 * 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
7235 * 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
7236 * 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
7237 * 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
7238 * 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
7239 * 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
7240 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7241 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
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 _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
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
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7246 /*
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
7247 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 * 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
7250 * item: Window handle of the item to pack.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7257 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
7258 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7259 /* 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
7260 * 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
7261 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7262 _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
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
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 * 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
7267 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7268 * 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
7269 * 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
7270 * 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
7271 * 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
7272 * 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
7273 * 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
7274 * 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
7275 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7276 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
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 _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
7279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 /*
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7282 * 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
7283 * 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
7284 */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7285 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
7286 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7287 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
7288
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7289 if(thisbox)
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 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
7292 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
7293 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
7294 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
7295 RECT rc = { 0 } ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7296
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7297 /* Calculate space requirements */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7298 _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
7299
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7300 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
7301 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
7302
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7303 /* 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
7304 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
7305
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7306 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
7307 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
7308 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7309 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7312 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7313 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7318 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7320 /* 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
7321 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
7322 _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
7323
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
7324 /* 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
7325 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 /*
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
7329 * 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
7330 * 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
7331 * 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
7332 * 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
7333 * 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
7334 */
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 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
7336 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7337 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
7338
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
7339 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
7340
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7341 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
7342 {
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
7343 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
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 /* 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
7346 _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
7347
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 /* 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
7349 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
7350 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
7351 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7352 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
7353 {
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
7354 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
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 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
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 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
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 /* 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
7361 _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
7362
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 /* 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
7364 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
7365 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
7366 }
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 }
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 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
7369 _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
7370 }
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
7371
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7375 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7377 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7383 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7385 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 /* 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
7389 unsigned long API dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7391 int bpp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7392 HDC hdc = GetDC(HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7393
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7394 bpp = GetDeviceCaps(hdc, BITSPIXEL);
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 ReleaseDC(HWND_DESKTOP, hdc);
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 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7399 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7400
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7401 /*
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7402 * 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
7403 * 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
7404 * Parameters:
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7405 * 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
7406 * 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
7407 * 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
7408 */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7409 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
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 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
7412 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
7413 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7414
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7415 /* 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
7416 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
7417 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7418 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
7419 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
7420
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7421 /* 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
7422 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
7423 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7424 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
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 /* 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
7427 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
7428 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
7429 /* 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
7430 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
7431 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
7432 /* 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
7433 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
7434 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
7435 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
7436 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
7437
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7438 /* 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
7439 *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
7440 *y = newy;
1493
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7441
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7442 /* Adjust the values to avoid Taskbar if requested */
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7443 if((horz | vert) & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7444 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7445 POINT pt = { 0, 0 };
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7446 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7447 MONITORINFO mi;
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7448
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7449 mi.cbSize = sizeof(MONITORINFO);
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 GetMonitorInfo(mon, &mi);
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 if(horz & DW_GRAV_OBSTACLES)
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 & 0xf) == DW_GRAV_LEFT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7456 *x += (mi.rcWork.left - mi.rcMonitor.left);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7457 else if((horz & 0xf) == DW_GRAV_RIGHT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7458 *x -= (mi.rcMonitor.right - mi.rcWork.right);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7459 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7460 if(vert & DW_GRAV_OBSTACLES)
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 & 0xf) == DW_GRAV_TOP)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7463 *y += (mi.rcWork.top - mi.rcMonitor.top);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7464 else if((vert & 0xf) == DW_GRAV_BOTTOM)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7465 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7466 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7467 }
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7468 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7469 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7478 void API dw_window_set_pos(HWND handle, long x, long y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7480 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
7481 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
7482
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 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
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 /* 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
7486 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
7487 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
7488
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7489 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
7490 _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
7491 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7492 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7503 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
7504 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7505 /* 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
7506 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
7507 _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
7508
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7509 _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
7510 /* 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
7511 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7523 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
7524 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7525 WINDOWPLACEMENT wp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7526
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7527 wp.length = sizeof(WINDOWPLACEMENT);
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 GetWindowPlacement(handle, &wp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7530 if( wp.showCmd == SW_SHOWMAXIMIZED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7531 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7532 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7533 *x=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7534 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7535 *y=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7536 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7537 *width=dw_screen_width();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7538 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7539 *height=dw_screen_height();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7540 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7541 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7542 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7543 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7544 *x = wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7545 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7546 *y = wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7547 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7548 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7549 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7550 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7551 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7561 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 {
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
7563 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
7564 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
7565 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
7566
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7567 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
7568 return;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7569
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
7570 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
7571 {
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 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
7573 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
7574 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
7575
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7576 _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
7577 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
7578
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 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
7580 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
7581 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
7582 }
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
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7584 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
7585
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
7586 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
7587 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7588
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7589 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7590 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7591 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
7592 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7593 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
7594
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7595 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
7596 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7597 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
7598
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
7599 /* 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
7600 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
7601 _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
7602
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7603 return;
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7604 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7605 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7606 #endif
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7607
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7608 tmp = currentstyle | mask;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7609 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
7610 tmp |= style & mask;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7611
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
7612 /* 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
7613 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
7614 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
7615 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
7616 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7617 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
7618 #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
7619 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
7620 {
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
7621 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
7622
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7623 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
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 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
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 /* 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
7628 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
7629 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
7630 _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
7631 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7632 else
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 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
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 /* 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
7637 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
7638 _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
7639 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7640 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7641 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7642 }
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7643 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
7644 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7645 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
7646 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
7647 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
7648
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7649 /* 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
7650 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
7651 tmp ^= thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7652 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
7653
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7654 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
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(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
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(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7659 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
7660 else
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7661 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7662 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
7663 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
7664 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
7665
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7666 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
7667 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
7668 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7669 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7670 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
7671 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
7672 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7673 /* 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
7674 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
7675 tmp &= ~(0xFL);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7676 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
7677 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
7678 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
7679 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
7680 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
7681 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
7682 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7683
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7684 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
7685 }
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
7686
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 /* 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
7688 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
7689 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7690 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7691
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7692 for(z=0;z<256;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 if(array[z] && array[z]->realid == pageid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7695 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7696 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7697 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7699
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7707 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7709 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
7710
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7711 if(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 int z, refid = -1;
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 for(z=0;z<256;z++)
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 if(_findnotebookid(array, z) == -1)
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 refid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7720 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7721 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7722 }
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 if(refid == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7725 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7726
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7727 for(z=0;z<256;z++)
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 if(!array[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 array[z] = calloc(1, sizeof(NotebookPage));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7732 array[z]->realid = refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7733 array[z]->item.mask = TCIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7734 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
7735 array[z]->item.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7736 TabCtrl_InsertItem(handle, z, &(array[z]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7737 return refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7738 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7739 }
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 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7743
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7744 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7746 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7751 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
7752 {
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
7753
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7754 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
7755 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7756
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7757 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7758 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7759
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7760 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && array[pageid])
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 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
7765 array[pageid]->item.pszText = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7766 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7767 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7768 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7769 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7770
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7771 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7772 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7773 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7778 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7780 }
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 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7786 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7788 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7789 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
7790 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7791 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
7792 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7793
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7794 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7795 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7796
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7797 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && array[pageid])
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 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
7802
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7803 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
7804 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7805 dw_window_destroy(array[pageid]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7806 array[pageid]->hwnd = tmpbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7807 if(pageidx == dw_notebook_page_get(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7808 {
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
7809 ShowWindow(tmpbox, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7810 SetParent(tmpbox, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7811 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7812 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7813 }
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
7814 }
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
7815
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 * 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
7818 * 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
7819 * 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
7820 * 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
7821 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7822 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
7823 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7824 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
7825 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
7826 HWND pagehwnd = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7827
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7828 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7829 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7830
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7831 pageid = _findnotebookid(array, pageidx);
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 if(pageid < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7834 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7835
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7836 if(array[pageid])
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 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
7839 pagehwnd = array[pageid]->hwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7840 free(array[pageid]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7841 array[pageid] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7842 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7843
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7844 TabCtrl_DeleteItem(handle, pageid);
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 /* Shift the pages over 1 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7847 for(z=pageid;z<255;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7848 array[z] = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7849 array[255] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7851 for(z=0;z<256;z++)
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 if(array[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 newid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7856 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7857 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7858 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7859 if(newid > -1)
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 SetParent(array[newid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7862 _resize_notebook_page(handle, newid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7863 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
7864 }
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
7865 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
7866 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
7867 }
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
7868
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 * 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
7871 * 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
7872 * 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
7873 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7874 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
7875 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7876 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
7877 int physid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7878
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7879 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
7880 return array[physid]->realid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7881 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
7882 }
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
7883
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 * 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
7886 * 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
7887 * 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
7888 * 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
7889 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7890 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
7891 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7892 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
7893 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7894
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7895 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7896 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7897
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7898 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && pageid < 256)
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 int oldpage = TabCtrl_GetCurSel(handle);
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 if(oldpage > -1 && array && array[oldpage])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7905 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7906
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7907 TabCtrl_SetCurSel(handle, pageid);
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 SetParent(array[pageid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7910 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7911 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7920 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7922 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7923
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7924 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7925
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7926 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
7927 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7928 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
7929 0, (LPARAM)UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7930 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7931 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7932 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
7933 0, (LPARAM)UTF8toWide(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7935
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7936 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7937 * 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
7938 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7939 * 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
7940 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7941 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7942 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7943 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
7944 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7945 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7946 int listbox_type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7947 int i;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7949 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7950
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7951 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
7952 listbox_type = CB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7953 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7954 listbox_type = LB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7955
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7956 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
7957 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
7958 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7959
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7960 /*
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7961 * 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
7962 * Parameters:
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7963 * handle: Handle to the listbox to be appended to.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7964 * text: Text to append into listbox.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7965 * pos: 0 based position to insert text
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7966 */
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7967 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
7968 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7969 TCHAR tmpbuf[100] = {0};
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7970
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7971 GetClassName(handle, tmpbuf, 99);
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7972
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7973 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7974 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7975 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
7976 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7977 else
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7978 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7979 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
7980 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7981 }
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7982
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7983 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7984 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7988 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7990 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7991
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7992 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7993
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7994 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
7995 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7996 char *buf = dw_window_get_text(handle);
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 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7999 CB_RESETCONTENT, 0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8000
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8001 if(buf)
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 dw_window_set_text(handle, buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8004 free(buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8005 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8006 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8007 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8008 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8009 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
8010 }
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
8011
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 * 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
8014 * 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
8015 * 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
8016 * 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
8017 * 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
8018 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8019 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
8020 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8021 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8022
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8023 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8024
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8025 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
8026 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8027 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8028 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
8029 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8030 else
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 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
8033 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8034 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
8035 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8036 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
8037 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8040 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8041 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8048 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
8049 {
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8050 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
8051 unsigned int len;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8052
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
8053 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
8054
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 if(!buffer || !length)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8056 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8057
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8058 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8059
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8060 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
8061 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8062 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
8063
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
8064 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
8065 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8066 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
8067 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
8068 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8069 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8070 else
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 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
8073
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
8074 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
8075 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8076 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
8077 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
8078 }
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8079 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086 */
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
8087 int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8089 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8090
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8091 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8092
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8093 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
8094 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8095 CB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8096 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8097
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8098 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8099 LB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8100 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8104 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8105 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8109 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8111 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
8112 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8113
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8114 GetClassName(handle, tmpbuf, 99);
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 /* 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
8117 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
8118 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8120 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
8121 if(count > 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8122 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8123 array = malloc(sizeof(int)*count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8124 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
8125
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8126 if(where == -1)
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 int ret = array[0];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8129 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8130 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8131 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8132 for(z=0;z<count;z++)
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 if(array[z] == where && (z+1) < count)
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 int ret = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8137 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8138 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8139 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8140 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8141 free(array);
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 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8153 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8155 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8156
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8157 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8158
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8159 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
8160 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8161 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8162 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8163 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8164 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
8165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8166 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8168
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8175 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8177 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8178
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8179 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8180
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8181 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
8182 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8183 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8184 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
8185 }
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
8186
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 * 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
8189 * 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
8190 * 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
8191 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8192 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
8193 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8194 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8195
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8196 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8197
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8198 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
8199 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8200 CB_GETCOUNT,0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8201
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8202 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8203 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
8204 }
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
8205
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 * 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
8208 * 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
8209 * 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
8210 * 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
8211 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8212 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
8213 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8214 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8215
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8216 GetClassName(handle, tmpbuf, 99);
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 /* 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
8219 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
8220 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8221
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8222 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
8223 }
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
8224
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8225 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8232 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8234 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
8235 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8236
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8237 if(startpoint < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8238 startpoint = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8239
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8240 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
8241 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
8242
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8243 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
8244
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8245 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8246 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8247 TCHAR *dest, *start;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8248 int copylen = len - startpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8249
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8250 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8251
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
8252 dest = &tmpbuf[startpoint+textlen];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8253 start = &tmpbuf[startpoint];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8254
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8255 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
8256 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
8257 }
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8258 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
8259
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8260 SetWindowText(handle, tmpbuf);
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 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
8263 return (startpoint + textlen);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8265
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 * 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
8270 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8272 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8274 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8275 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8276 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
8277 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
8278
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8279 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8280 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8281
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8282 buffer[0] = 0;
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 if(startpoint < len)
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 max = MIN(length, len - startpoint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8287
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8288 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8289 buffer[max] = '\0';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8290 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8291
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8292 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8293 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8294
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8302 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8304 if(bytes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8305 *bytes = GetWindowTextLength(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8306 if(lines)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8307 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8311 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8317 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8319 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
8320 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
8321
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8322 GetWindowText(handle, tmpbuf, len+1);
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 if(startpoint + length < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8325 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8326 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8327
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8328 SetWindowText(handle, tmpbuf);
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8331 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8334 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8337 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8339 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8340 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8341 SetWindowText(handle, TEXT(""));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8344 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8345 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 * 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
8347 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8350 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8352 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
8353 dw_mle_set_cursor(handle, point);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8355
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8357 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8358 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8359 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8360 * 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
8361 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8362 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
8363 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8364 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
8365 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8366
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 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8369 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8370 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8371 * 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
8372 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8373 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
8374 {
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
8375 /* 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
8376 * horizontal scrollbar it word wraps.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8377 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8378 if(state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8379 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
8380 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8381 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
8382 /* 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
8383 if(hrichedit)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8384 {
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8385 if(state)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8386 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
8387 else
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_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
8389 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8390 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8391
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8392 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8393 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8398 void API dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 {
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8400 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
8401 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8412 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8414 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
8415 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
8416 TCHAR *searchtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8417 int z, textlen, retval = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8418
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8419 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8420
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
8421 textlen = (int)strlen(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8422
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8423 if(flags & DW_MLE_CASESENSITIVE)
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 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
8426 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8427 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
8428 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8429 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8430 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8431 else
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 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
8434 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8435 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
8436 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8437 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8438 }
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 if(retval)
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 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
8443 SendMessage(handle, EM_SCROLLCARET, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8444 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8445
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8446 free(tmpbuf);
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 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8453 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8456 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8458 }
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 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8465 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
8470 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471 * 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
8472 * 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
8473 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8475 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 {
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
8477 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
8478 {
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 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
8480 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
8481 {
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 /* 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
8483 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
8484 /* 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
8485 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
8486 }
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 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
8488 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
8489 }
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 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
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 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
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 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
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 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
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 /* 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
8499 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
8500 /* 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
8501 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
8502 }
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 }
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 /* 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
8505 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
8506 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8507 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8510 * 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
8511 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8512 * 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
8513 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8514 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
8515 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8516 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
8517 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8518
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8519 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8520 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
8521 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
8522 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8523
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 * 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
8526 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8527 * 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
8528 * 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
8529 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8530 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
8531 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8532 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
8533 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8534
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8535 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8536 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
8537 else
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)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
8539 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8540
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8541 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8542 * 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
8543 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8544 * 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
8545 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8546 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
8547 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8548 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
8549 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8550
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 * 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
8553 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8554 * 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
8555 * 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
8556 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8557 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
8558 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
8559 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
8560 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
8561 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8562
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 * 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
8565 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8566 * 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
8567 * 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
8568 * 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
8569 */
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 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
8571 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8572 SCROLLINFO si;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8573
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8574 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8575 si.fMask = SIF_RANGE | SIF_PAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8576 si.nMin = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8577 si.nMax = range - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8578 si.nPage = visible;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8579 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
8580 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8581
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8582 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8588 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8590 TCHAR tmpbuf[101] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8591 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8592
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8593 _sntprintf(tmpbuf, 100, TEXT("%ld"), position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8594
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8595 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8596 SetWindowText(cinfo->buddy, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8597
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
8598 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 * 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
8605 * 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
8606 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8608 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 {
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
8610 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8619 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8621 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
8622 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8629 long API dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 {
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
8631 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8637 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8639 int API dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8640 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8641 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
8642 return (in_checkbox_handler ? FALSE : TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8643 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8644 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8645
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8646 /* 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
8647 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
8648 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8649 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8650
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8651 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8652
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8653 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
8654 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8655 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
8656 SendMessage(handle, BM_SETCHECK, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8657 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8658 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
8659 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8660 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8661 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8662 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8663 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8664 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8665 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8666 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8667 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8668 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
8669 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8670 HWND parent = GetParent(handle);
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 if(parent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8673 EnumChildWindows(parent, _uncheck_radios, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8674 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8675 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8679 * 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
8680 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8681 * 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
8682 * 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
8683 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8684 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8685 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8686 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8687 */
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
8688 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
8689 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8690 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8691 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8692 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8693 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8694
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8695 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8696 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8697
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8698 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
8699 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
8700 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
8701 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8702 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
8703
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8704 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8705 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8706 tvins.hInsertAfter = item ? item : TVI_FIRST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8707
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8708 hti = TreeView_InsertItem(handle, &tvins);
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 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8711 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8712
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8713 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8714 * 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
8715 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8716 * 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
8717 * 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
8718 * 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
8719 * 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
8720 * 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
8721 */
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
8722 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
8723 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8724 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8725 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8726 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8727 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8729 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8730 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8731
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8732 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
8733 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
8734 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
8735 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8736 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
8737
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8738 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8739 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8740 tvins.hInsertAfter = TVI_LAST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8741
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8742 hti = TreeView_InsertItem(handle, &tvins);
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 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
8745 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8746
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8747 /*
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
8748 * 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
8749 * 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
8750 * 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
8751 * 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
8752 * 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
8753 * 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
8754 */
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
8755 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
8756 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8757 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8758 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8759
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8760 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8761 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8762
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8763 if(TreeView_GetItem(handle, &tvi))
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8766 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8767 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8768
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8769 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
8770 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
8771 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8772 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
8773 tvi.hItem = (HTREEITEM)item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8774
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8775 TreeView_SetItem(handle, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8776 }
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
8777 }
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
8778
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 * 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
8781 * 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
8782 * 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
8783 * 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
8784 * 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
8785 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8786 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
8787 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8788 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8789 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8790
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8791 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8792 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8793
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8794 if(TreeView_GetItem(handle, &tvi))
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8797 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8798 }
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
8799 }
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
8800
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 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8802 * 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
8803 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8804 * 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
8805 * 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
8806 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8807 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
8808 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8809 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8810 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8811
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
8812 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8813 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8814
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8815 if(TreeView_GetItem(handle, &tvi))
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8818 return ptrs[1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8819 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8820 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
8821 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8822
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8823 /*
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8824 * 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
8825 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8826 * 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
8827 * 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
8828 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8829 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
8830 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8831 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8833 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8834 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8835
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8836 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
8837 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
8838 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
8839 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8840
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 * 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
8843 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8844 * 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
8845 * 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
8846 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8847 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
8848 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8849 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
8850 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8851
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8852 /*
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
8853 * 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
8854 * 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
8855 * 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
8856 * 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
8857 */
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
8858 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
8859 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8860 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
8861 }
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
8862
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8863 /* 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
8864 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
8865 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8866 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8867
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8868 hti = TreeView_GetChild(handle, node);
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 while(hti)
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 HTREEITEM lastitem = 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 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8875 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8876 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8877 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8878
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
8879 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8880 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8881 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8882 * 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
8883 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8884 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
8885 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8886 HTREEITEM hti = TreeView_GetRoot(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8887
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8888 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
8889 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8890 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8891 HTREEITEM lastitem = 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 _dw_tree_item_delete_recursive(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8894 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8895 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8896 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8897 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
8898 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8899
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8900 /*
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
8901 * 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
8902 * 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
8903 * 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
8904 * 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
8905 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8906 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
8907 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8908 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
8909 }
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
8910
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 * 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
8913 * 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
8914 * 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
8915 * 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
8916 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8917 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
8918 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8919 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
8920 }
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
8921
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 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8923 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8924 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8925 * 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
8926 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8927 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8928 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
8929 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8930 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8931 void **ptrs=NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8932
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8933 if(item == TVI_ROOT || !item)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8934 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8935
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8936 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8937 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8938
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8939 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8940 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8941
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8942 _dw_tree_item_delete_recursive(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8943 TreeView_DeleteItem(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8944 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8945 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
8946 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8947
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8948 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8955 * 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
8956 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8957 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8958 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
8959 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8960 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8961 int z, l = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8962 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
8963 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8964
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8965 if(separator == -1)
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 tempflags[0] = DW_CFA_RESERVED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8968 l = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8969 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8970
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8971 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
8972 tempflags[count + l] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8973 cinfo->flags = tempflags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8974 cinfo->columns = count + l;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8975
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8976
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8977 for(z=0;z<count;z++)
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 if(titles[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 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
8982 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
8983 lvc.cchTextMax = (int)_tcslen(lvc.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8984 if(flags[z] & DW_CFA_RIGHT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8985 lvc.fmt = LVCFMT_RIGHT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8986 else if(flags[z] & DW_CFA_CENTER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8987 lvc.fmt = LVCFMT_CENTER;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8988 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8989 lvc.fmt = LVCFMT_LEFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8990 lvc.cx = 75;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8991 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8992 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
8993 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8994 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8995 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
8996 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8997 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8999 /*
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9000 * 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
9001 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9002 * 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
9003 * 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
9004 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9005 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
9006 {
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
9007 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
9008
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9009 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
9010 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9011
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9012 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9013 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9014 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9015 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9017 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9018 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9019 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9020 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9021 {
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9022 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
9023 LV_COLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9024
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9025 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
9026 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
9027 lvc.cchTextMax = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9028 lvc.fmt = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9029 if(!count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9030 lvc.cx = 300;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9031 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9032 lvc.cx = 150;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9033 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9034 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
9035 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
9036 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9037 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9038 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
9039 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
9040 }
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
9041 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9042 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 */
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
9052 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
9053 {
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 return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9055 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9056
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9057 /*
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
9058 * 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
9059 * 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
9060 * 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
9061 * 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
9062 * (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
9063 */
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
9064 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
9065 {
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
9066 #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
9067 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
9068 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9069 char *file = malloc(strlen(filename) + 5);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9070 HANDLE icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9071
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9072 if(!file)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9073 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9074
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9075 strcpy(file, filename);
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 /* 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
9078 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9079 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9080 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9081 strcat(file, ".ico");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9082 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9083 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9084 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9085 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9086 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9087 }
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9088 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
9089 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
9090 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
9091 #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
9092 }
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
9093
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 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9095 * 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
9096 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9097 * 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
9098 * 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
9099 * (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
9100 */
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
9101 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
9102 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
9103 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
9104 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
9105 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
9106
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9107 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
9108 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
9109 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
9110 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
9111 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9112 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
9113 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
9114 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9115 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
9116 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
9117 #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
9118 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
9119 #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
9120 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
9121 #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
9122 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9123 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9124 {
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
9125 _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
9126 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
9127 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
9128 }
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
9129 _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
9130 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
9131 }
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
9132 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
9133 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9134
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9135 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9136 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9137 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9138 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 */
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
9140 void API dw_icon_free(HICN handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9142 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9147 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9148 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9149 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9151 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9152 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9153 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9154 int z, item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9155
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9156 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
9157 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9158 /* Insert at the end */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9159 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
9160 lvi.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9161 lvi.cchTextMax = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9162 lvi.iImage = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9163
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9164 ShowWindow(handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9165 item = ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9166 for(z=1;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9167 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
9168 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
9169 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
9170 }
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
9171
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 /* 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
9173 * 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
9174 */
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 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
9176 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9177 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9178 static HWND lasthwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9179
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
9180 /* 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
9181 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
9182 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
9183
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9184 if(!hSmall || !hLarge)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9185 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9186 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
9187 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
9188 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9189 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
9190 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9191 if(!lookup[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 lookup[z] = hicon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9194 ImageList_AddIcon(hSmall, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9195 ImageList_AddIcon(hLarge, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9196 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9197 {
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
9198 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9199 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9200 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9201 {
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
9202 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
9203 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9204 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9205 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9206 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9207 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9208
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9209 if(hicon == lookup[z])
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(lasthwnd != handle)
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(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9214 {
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
9215 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9216 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9217 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9218 {
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
9219 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
9220 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9221 }
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9222 lasthwnd = handle;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9223 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9224 return z;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9227 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
9228 }
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
9229
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 * 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
9232 * 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
9233 * 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
9234 * 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
9235 * 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
9236 * 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
9237 * 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
9238 */
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
9239 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
9240 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9241 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
9242 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9243
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 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
9245 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9246 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
9247 }
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9248
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9249 lvi.iItem = row + item;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9250 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9251 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
9252 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
9253 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9254 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
9255
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9256 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
9257 }
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
9258
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 * 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
9261 * 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
9262 * 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
9263 * 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
9264 * 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
9265 * 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
9266 * 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
9267 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9268 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
9269 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9270 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9274 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9276 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9277 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9278 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9279 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9280 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9281 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9282 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
9283 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9284 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9285 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9286 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
9287 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
9288 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9289
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 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
9291 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9292 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
9293 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9294
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9295 if(!cinfo || !cinfo->flags)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9296 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9297
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9298 flags = cinfo->flags;
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 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9301 lvi.iItem = row + item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9302 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
9303 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
9304 lvi.cchTextMax = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9305
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9306 if(flags[column] & DW_CFA_BITMAPORICON)
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 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9309 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
9310
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9311 if(data)
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 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
9314
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9315 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
9316 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9317 else
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9318 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
9319 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9320 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
9321 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9322 char *tmp = *((char **)data);
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 if(!tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9325 tmp = "";
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9326
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9327 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
9328 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
9329 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9330 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
9331 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9332 ULONG tmp = *((ULONG *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9333
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9334 _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
9335
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9336 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9337 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9338 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
9339 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9340 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9341 CDATE cdate = *((CDATE *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9342
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9343 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
9344
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9345 /* 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
9346 * Visual Studio 2008. -Brian
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9347 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9348 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
9349 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9350 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
9351 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
9352 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
9353 _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
9354 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9355
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9356 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9357 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9358 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
9359 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9360 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9361 CTIME ctime = *((CTIME *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9362
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9363 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
9364 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
9365 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
9366
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9367 _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
9368
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9369 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9370 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9371
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9372 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
9373 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9374
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9375 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9376 * 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
9377 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9378 * 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
9379 * 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
9380 * 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
9381 * 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
9382 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9383 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
9384 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9385 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
9386 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9387
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9388 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9389 * 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
9390 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9391 * 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
9392 * 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
9393 * 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
9394 * 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
9395 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9396 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
9397 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9398 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
9399 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9400
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 * 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
9403 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9404 * 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
9405 * 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
9406 * 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
9407 * 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
9408 * 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
9409 */
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
9410 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
9411 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9412 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
9413 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9414
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9415 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9416 * 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
9417 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9418 * 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
9419 * 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
9420 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9421 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
9422 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9423 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9424 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9425 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9426
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9427 if(!cinfo || !cinfo->flags)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9428 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9429
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9430 flags = cinfo->flags;
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 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9433 rc = DW_CFA_BITMAPORICON;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9434 else if(flags[column] & DW_CFA_STRING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9435 rc = DW_CFA_STRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9436 else if(flags[column] & DW_CFA_ULONG)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9437 rc = DW_CFA_ULONG;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9438 else if(flags[column] & DW_CFA_DATE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9439 rc = DW_CFA_DATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9440 else if(flags[column] & DW_CFA_TIME)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9441 rc = DW_CFA_TIME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9442 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9443 rc = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9444 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
9445 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9446
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 * 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
9449 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9450 * 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
9451 * 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
9452 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9453 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
9454 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9455 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
9456 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9457
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9458 /*
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9459 * 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
9460 * Parameters:
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9461 * 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
9462 * 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
9463 * 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
9464 * 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
9465 * 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
9466 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9467 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
9468 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9469 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
9470 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
9471 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
9472 temp = _internal_color(evencolor);
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9473 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
9474
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9475 /* Drop out on error */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9476 if(!cinfo)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9477 return;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9478
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9479 /* 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
9480 if(oddcolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9481 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
9482 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9483 cinfo->odd = oddcolor;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9484
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9485 if(evencolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9486 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
9487 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9488 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
9489 }
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9490
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9491 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9492 * 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
9493 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9494 * 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
9495 * 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
9496 * 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
9497 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9498 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
9499 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9500 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9501 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9502
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
9503 /* 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
9504 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
9505 {
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 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
9507 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9508
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
9509 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
9510 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9511 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
9512 }
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
9513
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 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
9515 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
9516 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
9517 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
9518
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 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
9520 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
9521
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 }
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9524 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9525 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9526 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9527 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9528 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9529 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9530 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9531 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9532 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9533 _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
9534 }
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
9535
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 * 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
9538 * 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
9539 * 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
9540 * 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
9541 * 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
9542 */
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 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
9544 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9545 _dw_container_set_row_title(handle, NULL, row, title);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9549 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9555 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9557 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 * 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
9564 * 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
9565 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9566 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9568 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9571 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9572 * 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
9573 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9574 * 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
9575 * 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
9576 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9577 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
9578 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9579 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
9580
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9581 for(z=0;z<rowcount;z++)
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 ListView_DeleteItem(handle, 0);
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 if(rowcount > _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9586 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
9587 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9588 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
9589 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9590
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 * 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
9593 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9594 * 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
9595 * 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
9596 * 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
9597 * 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
9598 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9599 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
9600 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9601 switch(direction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9602 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9603 case DW_SCROLL_TOP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9604 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
9605 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9606 case DW_SCROLL_BOTTOM:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9607 ListView_Scroll(handle, 0, 10000000);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9608 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9609 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9610 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9611
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9612 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9617 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9618 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9619 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9620 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9621 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9622 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9623 int _index = ListView_GetNextItem(handle, -1, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9624
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9625 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9626 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9627
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9628 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9631 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9632
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9633 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9634
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9635 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
9636 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9647 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9649 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
9650 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
9651
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9652 _index = ListView_GetNextItem(handle, _index, flags);
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 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9655 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9656
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9657 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9660 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9661
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9662 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9663
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9664 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
9665 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9667
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9668 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9669 * 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
9670 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9671 * 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
9672 * 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
9673 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9674 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
9675 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9676 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
9677 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
9678
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9679 while ( index != -1 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9680 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9681 LV_ITEM lvi;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9686 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9687
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9688 ListView_GetItem( handle, &lvi );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9689
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
9690 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
9691 {
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
9692 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
9693
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9694 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
9695 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
9696 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
9697 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
9698 ListView_EnsureVisible( handle, index, TRUE );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9699 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9700 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9701
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9702 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
9703 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9704 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9705
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9706 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9707 * 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
9708 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9709 * 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
9710 * 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
9711 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9712 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
9713 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9714 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
9715 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
9716
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9717 while(index != -1)
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 LV_ITEM lvi;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9724 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9725
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9726 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9727
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
9728 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
9729 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9730 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
9731
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9732 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
9733 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
9734
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9735 ListView_DeleteItem(handle, index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9736 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9737 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9738
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9739 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
9740 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9741 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9742
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9743 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9744 * 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
9745 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9746 * 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
9747 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9748 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
9749 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9750 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9751 if(cinfo && cinfo->columns == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9752 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9753 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
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 else if(cinfo && cinfo->columns > 1)
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 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
9758 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
9759 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
9760 int index;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9761
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9762 /* Initialize with sizes of column labels */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9763 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9764 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9765 if(flags[z] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9766 columns[z] = 5;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9767 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9768 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9769 LVCOLUMN lvc;
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 lvc.mask = LVCF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9772 lvc.cchTextMax = 1023;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9773 lvc.pszText = text;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9774
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9775 if(ListView_GetColumn(handle, z, &lvc))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9776 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9777
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9778 if(flags[z] & DW_CFA_RESERVED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9779 columns[z] += 20;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9780 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9781 }
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 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
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 /* Query all the item texts */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9786 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9787 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9788 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9789 {
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
9790 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
9791
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9792 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
9793 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
9794
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9795 /* 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
9796 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
9797 width += 20;
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9798
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9799 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
9800 columns[z] = width;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9801 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9802
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9803 index = ListView_GetNextItem(handle, index, LVNI_ALL);
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
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9806 /* 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
9807 * 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
9808 * 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
9809 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9810 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9811 ListView_SetColumnWidth(handle, z, columns[z] + 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9813 free(columns);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9814 free(text);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9815 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9816 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9817
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9818 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9819 * 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
9820 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9821 * 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
9822 * 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
9823 * 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
9824 */
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
9825 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
9826 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9827 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9828
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9829 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9830 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
9831 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9832 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
9833 tnid.uCallbackMessage = WM_USER+2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9834 tnid.hIcon = (HICON)icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9835 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
9836 _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
9837 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9838 tnid.szTip[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9839
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9840 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
9841 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9842
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 * 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
9845 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9846 * 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
9847 * 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
9848 */
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
9849 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
9850 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9851 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9853 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9854 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
9855 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9856
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9857 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
9858 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9859
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9860 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9862 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9863 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9865 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9867 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9868 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9869 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9870 HWND tmp = CreateWindow(ObjectClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
9871 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9872 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
9873 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9874 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
9875 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9876 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9877 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9878 newbox->pad = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9879 newbox->type = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9880 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9881 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9882 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9883 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
9884 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
9885 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9886 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9892 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9894 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9896 HPEN hPen = TlsGetValue(_hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9897 HBRUSH hBrush = TlsGetValue(_hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9898 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
9899 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9900 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
9901 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
9902 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
9903 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9904
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9905 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9906 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
9907 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9908 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
9909
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9910 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
9911 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
9912 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
9913 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
9914 #endif
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
9915
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9916 DeleteObject(hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9917 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
9918 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
9919 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
9920 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9929 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9931 COLORREF background;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9932
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9933 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9934 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
9935
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9936 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
9937 TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9938 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9939 TlsSetValue(_background, (LPVOID)(uintptr_t)background);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9940 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9941
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9942 /* 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
9943 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9944 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9945 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9946 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9947 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9948 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9949 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9950 CHOOSECOLOR cc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9951 unsigned long newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9952 COLORREF acrCustClr[16] = {0};
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9954 value = _internal_color(value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9955 if(value == DW_RGB_TRANSPARENT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9956 newcolor = DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9957 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9958 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
9959 ZeroMemory(&cc, sizeof(CHOOSECOLOR));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9960 cc.lStructSize = sizeof(CHOOSECOLOR);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9961 cc.rgbResult = newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9962 cc.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9963 cc.lpCustColors = (LPDWORD)acrCustClr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9964 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9965 if (ChooseColor(&cc) == TRUE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9966 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
9967 return newcolor;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9968 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9969
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9971 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9975 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9977 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9978 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9979 #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
9980 /* 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
9981 * 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
9982 */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9983 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
9984 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9985 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9986
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9987 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9988 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9989 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9990 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9991 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9992 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9993
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9994 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
9995 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9996 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
9997 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10007 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10008 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10009 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
10010 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10011 #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
10012 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
10013 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
10014
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10015 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
10016 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
10017 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
10018 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
10019 else
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10020 return;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10021
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10022 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
10023 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
10024 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
10025 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10026 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10027 HPEN oldPen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10028
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10029 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10030 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10031 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10032 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10033 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10034 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10035
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10036 oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10037 MoveToEx(hdcPaint, x1, y1, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10038 LineTo(hdcPaint, x2, y2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10039 SelectObject(hdcPaint, oldPen);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10040 /* For some reason Win98 (at least) fails
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10041 * 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
10042 */
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10043 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
10044 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10045 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
10046 #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
10047 }
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
10048
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10049 /* 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
10050 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
10051 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10052 POINT *points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10053 int i;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10054
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10055 /*
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10056 * 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
10057 * 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
10058 * 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
10059 */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10060 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
10061
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10062 if(points)
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 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
10065 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10066 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
10067 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
10068 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10069 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
10070 && 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
10071 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10072 /* 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
10073 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
10074 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
10075 /* ... 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
10076 (*npoints)++;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10077 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10078 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10079 return points;
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
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10082 /* 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
10083 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10084 * handle: Handle to the window.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10085 * 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
10086 * 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
10087 * number of points
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10088 * x[]: X coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10089 * y[]: Y coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10090 */
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
10091 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
10092 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
10093 POINT *points = NULL;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10094
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10095 /* Sanity check */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10096 if(npoints < 1)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10097 return;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10098
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10099 #ifdef GDIPLUS
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 GpGraphics *graphics = NULL;
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 if(handle)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10104 GdipCreateFromHWND(handle, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10105 else if(pixmap)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10106 GdipCreateFromHDC(pixmap->hdc, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10107 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10108 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10109
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10110 /* 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
10111 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
10112 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
10113
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10114 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
10115 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10116 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
10117 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10118 GpBrush *brush = TlsGetValue(_gpBrush);
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 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
10121 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10122 else
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 GpPen *pen = TlsGetValue(_gpPen);
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 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
10127 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10128 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10129 GdipDeleteGraphics(graphics);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10130 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10131 #else
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10132 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10133 HDC hdcPaint;
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 if ( handle )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10136 hdcPaint = GetDC( handle );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10137 else if ( pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10138 hdcPaint = pixmap->hdc;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10139 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10140 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10141
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10142 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
10143 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10144 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
10145 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
10146
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10147 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
10148 Polygon( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10149 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10150 Polyline( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10151
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10152 SelectObject( hdcPaint, oldBrush );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10153 SelectObject( hdcPaint, oldPen );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10154 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10155
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10156 if ( !pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10157 ReleaseDC( handle, hdcPaint );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10158 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10159 #endif
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10160 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10161 free(points);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10162 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10163
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
10164 /* 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
10165 * 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
10166 * 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
10167 * 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
10168 * 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
10169 * 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
10170 * 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
10171 * 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
10172 * 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
10173 */
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
10174 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
10175 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10176 #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
10177 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
10178
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10179 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10180 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
10181 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
10182 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
10183 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10184 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10185
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10186 /* 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
10187 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
10188 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
10189
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10190 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
10191 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10192 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
10193
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10194 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
10195 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10196 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10197 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10198 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
10199
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10200 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
10201 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10202 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10203 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10204 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10205 RECT Rect;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10206
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10207 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10208 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
10209 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
10210 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
10211 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10212 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10213
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10214 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
10215 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
10216 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
10217 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10218 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
10219 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10220 ReleaseDC(handle, hdcPaint);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10221 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10222 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10223
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10224 /* 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
10225 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10226 * 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
10227 * 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
10228 * 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
10229 * 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
10230 * 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
10231 * 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
10232 * 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
10233 * 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
10234 * 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
10235 * 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
10236 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10237 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
10238 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10239 #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
10240 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
10241 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
10242
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10243 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10244 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
10245 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
10246 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
10247 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10248 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10249
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10250 /* 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
10251 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
10252 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
10253
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10254 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
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_FILL)
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 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
10259
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10260 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
10261 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10262 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10263 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
10264 }
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
10265 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10266 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10267 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
10268 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
10269 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
10270 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
10271 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
10272 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
10273 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
10274
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10275 /* 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
10276 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
10277 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
10278 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
10279
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10280 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
10281 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10282 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10283 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10284 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10285 HBRUSH oldBrush;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10286 HPEN oldPen;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10287 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
10288 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
10289 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
10290 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
10291
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10292 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10293 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
10294 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
10295 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
10296 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10297 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10298
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10299 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
10300 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
10301 else
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, 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
10303 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
10304 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
10305 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
10306 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10307 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
10308 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
10309 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
10310
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10311 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10312 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
10313 #endif
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10314 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10315
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10316 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10317 /* 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
10318 * 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
10319 */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10320 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
10321 {
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10322 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
10323 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
10324 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
10325 {
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10326 if(mult)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10327 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10328 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10329 *x *= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10330 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10331 *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
10332 }
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10333 else
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10334 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10335 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10336 *x /= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10337 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10338 *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
10339 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10340 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10341 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10342 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10343
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10344 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10345 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10350 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10351 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10352 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
10353 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10354 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10355 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10356 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
10357 ColorInfo *cinfo = NULL;
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10358 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
10359 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10360
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10361 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10362 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10363 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10364 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10365 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10366 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10367
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10368 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10369 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
10370 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
10371 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
10372 else if(pixmap->handle)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10373 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10374
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10375 if(cinfo)
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 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10378 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10379 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10380
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10381 background = (COLORREF)(uintptr_t)TlsGetValue(_background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10382 if(hFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10383 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
10384 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
10385 if(background == DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10386 SetBkMode(hdc, TRANSPARENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10387 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10388 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10389 SetBkMode(hdc, OPAQUE);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10390 SetBkColor(hdc, background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10391 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10392 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10393 _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
10394 #endif
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10395 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
10396 if(oldFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10397 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10398 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10399 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10400 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10401 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10403
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
10404 /* 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
10405 * 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
10406 * 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
10407 * 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
10408 * 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
10409 * 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
10410 * 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
10411 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
10412 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
10413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10414 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10415 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10416 HFONT hFont = NULL, oldFont;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10417 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
10418 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10419
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10420 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10421 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10422 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10423 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10424 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10425 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10426
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
10427 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
10428 {
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 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
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 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10432 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10433 ColorInfo *cinfo;
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 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10436 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10437 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10438 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10439
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10440 if(cinfo)
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 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10443 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10444 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10445 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10446 oldFont = SelectObject(hdc, hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10447
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10448 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
10449
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10450 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10451 *width = sz.cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10452
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10453 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10454 *height = sz.cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10455
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10456 #ifdef GDIPLUS
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10457 _convert_dpi(hdc, width, height, FALSE);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10458 #endif
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10459
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10460 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10461 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10462 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10463 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10464 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
10465 }
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
10466
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10468 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10470 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10472 }
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 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10476 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10477 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10478 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10479 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10480 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10481 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10482 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10483 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10484 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
10485 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10486 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10487 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10488
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10489 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10490 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10491
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10492 hdc = GetDC(handle);
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 pixmap->width = width; pixmap->height = height;
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->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10497 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10498 pixmap->hdc = CreateCompatibleDC(hdc);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10499 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10500
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10501 SelectObject(pixmap->hdc, pixmap->hbm);
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 ReleaseDC(handle, hdc);
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 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10507
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
10508 #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
10509 /* 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
10510 * 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
10511 * 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
10512 */
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 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
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 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
10516 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
10517 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
10518 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
10519 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
10520
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 /* 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
10522 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
10523 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
10524
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 /* 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
10526 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
10527 {
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 /* Couldn't read the file header */
967
c8490b0d8577 Minor formatting fix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 966
diff changeset
10529 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
10530 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
10531 }
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
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10533 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
10534 {
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
10535 /* 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
10536 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
10537 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
10538 }
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
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 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
10541 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
10542 {
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 /* 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
10544 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
10545 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
10546 }
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
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 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
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 /* 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
10551 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
10552 }
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 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
10554 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
10555 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
10556 }
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
10557 #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
10558
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10559 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10560 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10561 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10562 * 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
10563 * 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
10564 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10565 * (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
10566 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10567 * 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
10568 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10569 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
10570 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10571 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10572 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10573 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
10574 #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
10575 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
10576 #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
10577
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 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
10579 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
10580
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
10581 #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
10582 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
10583 #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
10584 file = _alloca(strlen(filename) + 5);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10585 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10586
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10587 /* 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
10588 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10589 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10590 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10591 strcat(file, ".bmp");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10592 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10593 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10594 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10595 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10596 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10597 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10598 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10599
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10600 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
10601 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
10602 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10603
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10604 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10605
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10606 if ( !pixmap->hbm )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10607 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10608 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10609 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10610 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10611
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
10612 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
10613
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10614 pixmap->hdc = CreateCompatibleDC( hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10615 GetObject( pixmap->hbm, sizeof(bm), &bm );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10616 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
10617 SelectObject( pixmap->hdc, pixmap->hbm );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10618 ReleaseDC( handle, hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10619 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10620
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10621 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10622 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10623
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10624 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10625 * 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
10626 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10627 * 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
10628 * 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
10629 * (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
10630 * 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
10631 * Returns:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10632 * 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
10633 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10634 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
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 pixmap;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10637 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
10638 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
10639 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
10640 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
10641
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10642 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
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 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
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
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10647 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
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 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
10650
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10651 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
10652 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
10653 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10654 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
10655 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
10656 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10657 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
10658 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
10659 #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
10660 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
10661 #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
10662 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
10663 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
10664 #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
10665 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10666 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10667 {
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
10668 _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
10669 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
10670 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
10671 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
10672 }
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
10673 _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
10674 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
10675 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10676
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10677 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
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 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
10680 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
10681 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
10682 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10683
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10684 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
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 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
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 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
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 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
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 ReleaseDC( handle, hdc );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10693 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10694
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10695 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
10696 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10697
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10698 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10699 * 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
10700 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10701 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
10702 {
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
10703 if ( pixmap && pixmap->depth < 32)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10704 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10705 pixmap->transcolor = _internal_color(color);
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 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10717 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10719 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10720 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10721 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10722
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10723 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10724 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10725
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10726 hdc = GetDC(handle);
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 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10729 pixmap->hdc = CreateCompatibleDC(hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10730
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10731 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
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 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
10734 pixmap->depth = bm.bmBitsPixel;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10735
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10736 SelectObject(pixmap->hdc, pixmap->hbm);
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 ReleaseDC(handle, hdc);
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10739 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10740
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10741 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10743
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10744 /*
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
10745 * 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
10746 * 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
10747 * 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
10748 * 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
10749 * 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
10750 * 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
10751 * 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
10752 * 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
10753 * 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
10754 */
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 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
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 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
10758 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
10759 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
10760
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
10761 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
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 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
10764 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
10765 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
10766 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
10767 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
10768 }
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 }
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 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
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
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10774 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10775 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10777 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10779 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10780 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10781 if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10782 {
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
10783 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
10784 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
10785 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
10786 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
10787 free(pixmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10788 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10795 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10803 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10805 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
10806 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10807 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
10808 }
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10809
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 * 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
10812 * Parameters:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10813 * 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
10814 * 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
10815 * 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
10816 * 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
10817 * 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
10818 * 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
10819 * 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
10820 * 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
10821 * 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
10822 * 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
10823 * 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
10824 * 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
10825 * Returns:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10826 * 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
10827 */
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10828 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
10829 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10830 HDC hdcdest;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10831 HDC hdcsrc;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10832 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
10833 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
10834
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10835 /* Do some sanity checks */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10836 if ( dest )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10837 hdcdest = GetDC( dest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10838 else if ( destp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10839 hdcdest = destp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10840 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
10841 return DW_ERROR_GENERAL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10842
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10843 if ( src )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10844 hdcsrc = GetDC( src );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10845 else if ( srcp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10846 hdcsrc = srcp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10847 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
10848 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
10849
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10850 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
10851 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
10852
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10853 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
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 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
10856 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
10857 }
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10858
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10859 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10860 /* 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
10861 _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
10862 _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
10863 _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
10864 _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
10865 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10866
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10867 /* 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
10868 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
10869 {
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10870 /* Don't do anything */
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 /* 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
10873 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
10874 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10875 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
10876 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10877 else
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10878 {
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10879 /* 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
10880 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
10881 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
10882 else
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10883 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
10884 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10885 if ( !destp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10886 ReleaseDC( dest, hdcdest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10887 if ( !srcp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10888 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
10889
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10890 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10891 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10892
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
10893 /* 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
10894 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
10895 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10896 int *info = (int *)data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10897
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10898 if(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 Beep(info[0], info[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10901 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10902 }
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
10903 }
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10904
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10905 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10906 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10907 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10908 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10909 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10910 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10911 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10912 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10913 int *info = malloc(sizeof(int) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10914
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10915 if(info)
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 info[0] = freq;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10918 info[1] = dur;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10919
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10920 _beginthread(_beepthread, 100, (void *)info);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10921 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10922 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10923
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10924 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10925 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10926 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10927 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10928 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10929 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10930 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10931 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10932 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
10933 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10934
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10935 *handle = LoadLibrary(UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10936 return (NULL == *handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10937 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10938
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10939 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10940 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10941 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10942 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10943 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10944 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10945 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10946 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
10947 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10948 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
10949 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10951 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
10952 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10954 *func = (void*)GetProcAddress(handle, name);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10955 return (NULL == *func);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10956 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10957
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10958 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10959 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10960 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10961 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10962 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10963 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10964 return FreeLibrary(handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10965 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10966
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10967 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10968 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10970 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10972 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10975 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10976 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10977 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10978 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10979 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10980 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10981 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10982 CloseHandle((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10983 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10984
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10985 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10986 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10987 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10988 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10989 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10990 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10991 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10992 if(_dwtid == dw_thread_id())
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10993 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10994 int rc = WaitForSingleObject((HANDLE)mutex, 0);
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 while(rc == WAIT_TIMEOUT)
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 dw_main_sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10999 rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11000 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11001 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
11002 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11003 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11004 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11005
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11006 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11007 * 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
11008 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11009 * 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
11010 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11011 * 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
11012 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11013 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
11014 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11015 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
11016 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
11017 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
11018 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11019
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11020 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11021 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11022 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11023 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11025 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11027 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11031 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11033 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 {
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
11035 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11038 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11039 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11041 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11043 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11044 {
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
11045 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
11046 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
11047 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11048 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11049
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11050 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11051 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11052 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11053 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11054 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11056 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11057 {
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
11058 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
11059 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
11060 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
11061 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11062
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11063 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11066 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11067 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11068 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11069 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11070 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11071 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11072
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
11073 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
11074 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
11075 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
11076 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
11077 return DW_ERROR_TIMEOUT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11078 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
11079 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
11080 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11081 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11082
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11085 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11086 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11088 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11089 {
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
11090 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
11091 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
11092 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
11093 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11094
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 /* 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
11096 * 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
11097 * 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
11098 * 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
11099 * 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
11100 * 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
11101 */
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 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
11103 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11104 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11105
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11106 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11107 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11108 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11109
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11110 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
11111 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11112
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 /* 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
11114 * 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
11115 * 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
11116 * 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
11117 */
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 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
11119 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11120 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
11121 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11122
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 /* 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
11124 * 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
11125 * 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
11126 * 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
11127 * 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
11128 */
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 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
11130 {
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
11131 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
11132 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
11133 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
11134 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11135
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 /* 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
11137 * 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
11138 * 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
11139 * 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
11140 * 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
11141 */
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 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
11143 {
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
11144 if(SetEvent(eve))
1170
4b94c9f5ddeb Missing return on Windows... surprised this compiled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
11145 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
11146 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
11147 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11148
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 /* 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
11150 * 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
11151 * 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
11152 * 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
11153 * 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
11154 * 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
11155 * 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
11156 */
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 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
11158 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11159 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11160
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
11161 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
11162 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
11163 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
11164 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
11165 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
11166 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
11167 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
11168 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
11169 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11170
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 /* 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
11172 * 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
11173 * 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
11174 * 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
11175 * 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
11176 */
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 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
11178 {
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
11179 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
11180 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
11181 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
11182 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11183
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 * 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
11186 * 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
11187 * 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
11188 * 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
11189 * 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
11190 * 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
11191 */
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 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
11193 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11194 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11195 HSHM handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11196
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11197 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11198 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11199 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11200
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11201 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
11202
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11203 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11204 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11205
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11206 *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
11207
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11208 if(!*dest)
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 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11211 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11212 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11213
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11214 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
11215 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11216
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 * 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
11219 * 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
11220 * 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
11221 * 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
11222 * 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
11223 */
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 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
11225 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11226 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
11227
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11228 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11229 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11230
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11231 *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
11232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11233 if(!*dest)
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 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11236 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11237 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11238
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11239 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
11240 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11241
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 * 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
11244 * 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
11245 * 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
11246 * 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
11247 */
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 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
11249 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11250 UnmapViewOfFile(ptr);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11251 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11252 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11253 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11254
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11255 /*
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11256 * Encapsulate thread creation on Win32.
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11257 */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11258 void _dwthreadstart(void *data)
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 (* threadfunc)(void *) = NULL;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11261 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
11262 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
11263 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
11264 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11265 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
11266 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
11267 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11268
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11269 _init_thread();
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 threadfunc = (void (*)(void *))tmp[0];
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11272 threadfunc(tmp[1]);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11273
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11274 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
11275 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
11276 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
11277 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
11278 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
11279 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11280 if((brush = TlsGetValue(_gpBrush)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11281 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
11282 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
11283 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
11284 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11285 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11286
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11287 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11288 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11289 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11290 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11291 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11292 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11293 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11294 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11295 {
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
11296 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11297 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
11298 #else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11299 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
11300
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11301 tmp[0] = func;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11302 tmp[1] = data;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11303
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11304 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
11305 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11306 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11308 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11309 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11310 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11311 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11312 {
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
11313 #if !defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11314 _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
11315 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11316 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11317
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11318 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11319 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11320 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11321 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11322 {
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
11323 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11324 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
11325 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11326 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
11327 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11328 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11329
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11330 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11331 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11332 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11333 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11334 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11335 void API dw_exit(int exitcode)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11336 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11337 OleUninitialize();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11338 #ifdef AEROGLASS
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11339 /* 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
11340 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
11341 #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
11342 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
11343 DestroyWindow(hwndTooltip);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11344 exit(exitcode);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11347 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11348 * 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
11349 * 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
11350 * 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
11351 * 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
11352 * 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
11353 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11354 * 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
11355 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11356 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
11357 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11358 HWND tmp = CreateWindow(SplitbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11359 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11360 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
11361 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11362 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
11363 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11364 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11365 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11366
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11367 if(tmp)
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 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
11370 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11371
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11372 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
11373 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
11374 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
11375
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11376 tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11377 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
11378 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
11379 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
11380 *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
11381 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
11382 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
11383 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11384 return tmp;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11385 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11386
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 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11389 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11390 * 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
11391 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11392 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
11393 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11394 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
11395 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
11396 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
11397
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11398 if(mypercent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11399 *mypercent = percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11400
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11401 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
11402
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
11403 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
11404 _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
11405 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11406
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 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11409 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11410 * 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
11411 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11412 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
11413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11414 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
11415
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11416 if(percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11417 return *percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11418 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11421 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11422 * Creates a calendar window (widget) with given parameters.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11423 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11424 * type: Value can be DW_VERT or DW_HORZ.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11425 * topleft: Handle to the window to be top or left.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11426 * bottomright: Handle to the window to be bottom or right.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11427 * Classname: SysMonthCal32
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11428 * Returns:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11429 * A handle to a calendar window or NULL on failure.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11430 */
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11431 HWND API dw_calendar_new(unsigned long id)
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11432 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11433 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11434 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11435 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11436 MONTHCAL_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11437 NULL,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11438 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
11439 0,0,0,0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11440 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
11441 (HMENU)(uintptr_t)id,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11442 DWInstance,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11443 NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11444 if ( tmp )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11445 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11446 // 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
11447 MonthCal_GetMinReqRect(tmp, &rc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11448 // 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
11449 SetWindowPos(tmp, NULL, 0, 0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11450 rc.right, rc.bottom,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11451 SWP_NOZORDER | SWP_NOMOVE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11452 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
11453 MonthCal_SetDayState(tmp,3,mds);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11454 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11455 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11456 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11457 return NULL;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11458 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11459
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 * Sets the current date of a calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11462 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11463 * 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
11464 * year: The year to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11465 * month: The month to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11466 * day: The day to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11467 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11468 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
11469 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11470 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11471 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11472 date.wYear = year;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11473 date.wMonth = month;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11474 date.wDay = day;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11475 if ( MonthCal_SetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11476 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11477 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11478 else
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11481 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
11482 MonthCal_SetDayState(handle,3,mds);
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11483 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11484
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 * Gets the date from the calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11487 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11488 * 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
11489 * year: Pointer to the year to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11490 * month: Pointer to the month to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11491 * day: Pointer to the day to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11492 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11493 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
11494 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11495 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11496 if ( MonthCal_GetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11497 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11498 *year = date.wYear;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11499 *month = date.wMonth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11500 *day = date.wDay;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11501 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11502 else
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 *year = *month = *day = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11505 }
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11506 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11507
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
11508 /* 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
11509 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
11510 {
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 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
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
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11514 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11515 * 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
11516 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11517 * 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
11518 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11519 * 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
11520 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11521 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
11522 {
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
11523 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
11524 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
11525 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
11526 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
11527 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11528
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11529 /*
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
11530 * 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
11531 * 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
11532 * 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
11533 * 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
11534 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11535 * 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
11536 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11537 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
11538 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11539 Box *thisbox = (Box *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11541 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11542 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
11543 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11544
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 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11546 * 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
11547 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11548 * 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
11549 * 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
11550 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11551 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
11552 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11553 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11554
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11555 if (cinfo)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11556 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11557 cinfo->clickdefault = next;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11558 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11559 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11560
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11561 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11562 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11563 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11564 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11565 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11566 * 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
11567 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11568 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11569 char * API dw_clipboard_get_text(void)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11570 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11571 HANDLE handle;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11572 char *ret = NULL;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11573 TCHAR *tmp;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11574 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11575 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11576 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11577 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11578 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11579
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11580 if ( !OpenClipboard( NULL ) )
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11581 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11582
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11583 if ( ( handle = GetClipboardData(type) ) == NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11584 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11585 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11586 return ret;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11587 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11588
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11589 if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) )
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11590 {
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11591 ret = _strdup(WideToUTF8(tmp));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11592 GlobalUnlock(handle);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11593 }
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11594 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11595 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11596 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11597
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 * 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
11600 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11601 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11602 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11603 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
11604 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11605 HGLOBAL ptr1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11606 LPTSTR ptr2;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11607 TCHAR *buf;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11608 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11609 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11610 char *src = calloc(len + 1, 1);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11611
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11612 memcpy(src, str, len);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11613 buf = UTF8toWide(src);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11614 free(src);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
11615 len = (int)_tcslen(buf);
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11616 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11617 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11618
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11619 buf = str;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11620 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11621
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11622 if ( !OpenClipboard( NULL ) )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11623 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11624
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11625 ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
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 if ( !ptr1 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11628 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11629
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11630 ptr2 = GlobalLock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11631
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11632 memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11633 GlobalUnlock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11634 EmptyClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11635
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11636 SetClipboardData( type, ptr1 );
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11637
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11638 CloseClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11639 GlobalFree( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11640 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11641
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11642 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11643 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11644 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11645 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11646 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11647 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11648 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11649 if(!env)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11650 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11651
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11652 /* Get the Windows version. */
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 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11655 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11656
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11657 /* 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
11658
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11659 env->MinorBuild = 0;
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 if (dwVersion < 0x80000000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11662 {
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11663 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
11664 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
11665 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
11666 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
11667 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
11668 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
11669 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
11670 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
11671 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
11672 strcpy(env->osName, "Windows 8");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11673 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11674 strcpy(env->osName, "Windows NT");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11675
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11676 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
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 else
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 strcpy(env->osName, "Windows 95/98/ME");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11681 env->MajorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11682 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11683
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11684 strcpy(env->buildDate, __DATE__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11685 strcpy(env->buildTime, __TIME__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11686 env->DWMajorVersion = DW_MAJOR_VERSION;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11687 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
11688 #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
11689 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
11690 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11691 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
11692 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11693 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11694
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11695 /* 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
11696 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
11697 {
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11698 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
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 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
11701 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11702 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
11703 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
11704 else
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11705 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
11706 x++;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11707 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11708 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
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
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11711 #define BROWSEBUFSIZE 1000
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11712
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11713 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11714 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11715 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11716 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11717 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11718 * 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
11719 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11721 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
11723 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11725 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11726 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11727 OPENFILENAME of = {0};
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11728 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
11729 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
11730 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
11731 TCHAR *dpath = UTF8toWide(defpath);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11732 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11733
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11734 if ( flags == DW_DIRECTORY_OPEN )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11735 {
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
11736 /* 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
11737 #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
11738 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
11739 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
11740 LPITEMIDLIST pidl;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11741 LPMALLOC pMalloc;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11742
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11743 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11744 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11745 bi.hwndOwner = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11746 bi.pszDisplayName = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11747 bi.pidlRoot = 0;
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11748 bi.lpszTitle = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11749 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11750 bi.lpfn = NULL; /*BrowseCallbackProc*/
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11751
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11752 pidl = SHBrowseForFolder(&bi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11753 if (pidl)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11754 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11755 if (SHGetPathFromIDList(pidl,szDir))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11756 {
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11757 _tcsncpy(filenamebuf,szDir,BROWSEBUFSIZE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11758 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11759
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11760 /* 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
11761 pMalloc->lpVtbl->Free(pMalloc,pidl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11762 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
11763 return _strdup(WideToUTF8(filenamebuf));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11764 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11765 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11766 #else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11767 if ( XBrowseForFolder( NULL,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11768 (LPCTSTR)dpath,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11769 -1,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11770 (LPCTSTR)UTF8toWide(title),
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11771 (LPTSTR)filenamebuf,
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11772 BROWSEBUFSIZE,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11773 FALSE ) )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11774 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11775 return _strdup( WideToUTF8(fbuf) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11776 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11777 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11779 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11780 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11781 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
11782
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11783 if (ext)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11784 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11785 /*
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11786 * 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
11787 * 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
11788 */
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11789 int len;
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11790 TCHAR *ptr = filterbuf;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11791 TCHAR *start = filterbuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11792
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11793 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
11794 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
11795 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
11796 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
11797 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
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("*.*") );
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11800 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11801
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11802 memset( &of, 0, sizeof(OPENFILENAME) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11803
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11804 of.lStructSize = sizeof(OPENFILENAME);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11805 of.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11806 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
11807 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
11808 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
11809 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
11810 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
11811 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
11812 _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
11813 of.lpstrFile = filenamebuf;
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11814 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
11815 of.nFilterIndex = 1;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11816 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
11817 /*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
11818 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
11819
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11820 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
11821 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11822 of.Flags |= OFN_OVERWRITEPROMPT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11823 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
11824 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11825 else
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11826 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11827 of.Flags |= OFN_FILEMUSTEXIST;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11828 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
11829 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11830
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11831 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
11832 return _strdup(WideToUTF8(of.lpstrFile));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11833 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11834 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11837 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11838 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11839 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11840 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11841 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11842 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11843 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11844 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11845 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11846 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11847 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11848 char **newparams;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11849 int retcode, count = 0, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11851 while(params[count])
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 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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11856 newparams = (char **)malloc(sizeof(char *) * (count+1));
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 for(z=0;z<count;z++)
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 newparams[z] = malloc(strlen(params[z])+3);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11861 strcpy(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11862 strcat(newparams[z], params[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11863 strcat(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11864 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11865 newparams[count] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11866
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
11867 /* 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
11868 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
11869
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11870 for(z=0;z<count;z++)
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 free(newparams[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);
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 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11879 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11880 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11882 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11883 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11884 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11885 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11886 char *browseurl = url;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11887 int retcode;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11888
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11889 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
11890 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11891 int len, z;
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 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
11894 len = (int)strlen(browseurl);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11895
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11896 for(z=0;z<len;z++)
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 if(browseurl[z] == '|')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11899 browseurl[z] = ':';
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11903 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11904
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11905 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
11906 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
11907 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
11908 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11910
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11911 typedef struct _dwprint
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11912 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11913 PRINTDLG pd;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11914 DOCINFO di;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11915 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
11916 void *drawdata;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11917 unsigned long flags;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11918 } DWPrint;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11919
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11920 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11921 * 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
11922 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11923 * 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
11924 * 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
11925 * 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
11926 * 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
11927 * 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
11928 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11929 * 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
11930 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11931 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
11932 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11933 DWPrint *print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11934
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11935 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
11936 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11937
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11938 print->drawfunc = drawfunc;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11939 print->drawdata = drawdata;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11940 print->pd.lStructSize = sizeof(PRINTDLG);
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11941 print->pd.hwndOwner = HWND_DESKTOP;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11942 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
11943 print->pd.nCopies = 1;
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11944 print->pd.nFromPage = 1;
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11945 print->pd.nToPage = pages;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11946 print->pd.nMinPage = 1;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11947 print->pd.nMaxPage = pages;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11948
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11949 if(!PrintDlg(&(print->pd)))
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11950 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11951 free(print);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11952 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11953 }
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11954
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11955 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
11956 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
11957 return print;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11958 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11959
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 * 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
11962 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11963 * 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
11964 * 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
11965 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11966 * 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
11967 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11968 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
11969 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11970 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11971 HPIXMAP pixmap;
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11972 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
11973
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11974 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
11975 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11976
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11977 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
11978 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11979
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11980 width = GetDeviceCaps(p->pd.hDC, HORZRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11981 height = GetDeviceCaps(p->pd.hDC, VERTRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11982
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11983 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
11984 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
11985 pixmap->transcolor = DW_RGB_TRANSPARENT;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11986
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11987 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11988 /* 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
11989 _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
11990 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11991
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11992 pixmap->width = width;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11993 pixmap->height = height;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11994
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11995 SelectObject(pixmap->hdc, pixmap->hbm);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11996
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11997 /* Start the job */
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11998 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
11999
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12000 /* Cycle through each page */
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12001 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
12002 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12003 StartPage(p->pd.hDC);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12004 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
12005 EndPage(p->pd.hDC);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12006 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12007 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
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 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
12010 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
12011 }
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 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
12013 AbortDoc(p->pd.hDC);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12014 /* Free memory */
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12015 dw_pixmap_destroy(pixmap);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12016 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
12017 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12018 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12019
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 * 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
12022 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12023 * 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
12024 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12025 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
12026 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12027 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12028
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12029 if(p)
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12030 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
12031 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12032
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12033 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12034 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12035 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12036 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12037 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12038 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12039 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12040 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
12041
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12042 if(!_user_dir[0])
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 HANDLE hToken = 0;
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
12045
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12046 /* 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
12047 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
12048 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12049 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
12050 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
12051
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12052 GetUserProfileDirectory(hToken, Buf, &BufSize);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12053 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
12054 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
12055 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12056 /* 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
12057 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12058 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12059 strcpy(_user_dir, "C:\\");
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 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12062 return _user_dir;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12065 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12066 * 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
12067 * 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
12068 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
12069 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
12070 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12071 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
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
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12074 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12075 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12076 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12077 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12078 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12079 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12080 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12081 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12082 {
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
12083 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12085
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12086 /* 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
12087 * 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
12088 * 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
12089 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12090 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
12091 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12092 UserData *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12093
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12094 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12095 {
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
12096 if(_stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12097 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12098 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12099 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12100 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
12101 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12102
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12103 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
12104 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12105 UserData *new = _find_userdata(root, varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12106
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12107 if(new)
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 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12110 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12111 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12112 else
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 new = malloc(sizeof(UserData));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12115 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12116 {
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
12117 new->varname = _strdup(varname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12118 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12120 new->next = NULL;
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 if (!*root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12123 *root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12124 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12125 {
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
12126 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
12127
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12128 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12129 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12130 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12131 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12132 }
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
12133 prev->next = new;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12134 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12135 return TRUE;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12138 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
12139 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12140
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12141 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
12142 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12143 UserData *prev = NULL, *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12144
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12145 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12146 {
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
12147 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
12148 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12149 if(!prev)
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 *root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12152 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12153 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12154 if(!all)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12155 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12156 tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12157 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12158 else
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 /* If all is true we should
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12161 * never get here.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12162 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12163 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12164 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12165 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12166 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12167 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12168 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12169 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12172 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12173 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12174 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12175 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
12176 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12177
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 * 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
12180 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12181 * 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
12182 * 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
12183 * 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
12184 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12185 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
12186 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12187 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12188
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12189 if(!cinfo)
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(!dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12192 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12193
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12194 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12195 cinfo->fore = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12196 SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12197 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12198
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12199 if(cinfo)
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(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12202 _new_userdata(&(cinfo->root), dataname, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12203 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12204 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12205 if(dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12206 _remove_userdata(&(cinfo->root), dataname, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12207 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12208 _remove_userdata(&(cinfo->root), NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12209 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12210 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12211 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12212
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 * 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
12215 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12216 * 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
12217 * 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
12218 * 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
12219 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12220 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
12221 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12222 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12223
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12224 if(cinfo && cinfo->root && dataname)
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 UserData *ud = _find_userdata(&(cinfo->root), dataname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12227 if(ud)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12228 return ud->data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12229 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12230 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
12231 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12232
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12233 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12234 * 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
12235 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12236 * 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
12237 * 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
12238 * 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
12239 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12240 * 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
12241 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12242 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
12243 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12244 if(sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12245 {
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
12246 /* 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
12247 * 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
12248 */
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 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
12250
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12251 if(timerid)
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 _new_signal(WM_TIMER, NULL, timerid, sigfunc, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12254 return timerid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12255 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12256 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12257 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
12258 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12259
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 * 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
12262 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12263 * 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
12264 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12265 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
12266 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12267 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12268
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12269 /* 0 is an invalid timer ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12270 if(!id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12271 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12272
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12273 KillTimer(NULL, id);
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 while(tmp)
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 if(tmp->id == id)
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(prev)
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 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12282 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12283 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12284 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12285 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12288 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12289 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12290 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12291 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12292 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12295 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12296 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12297 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12298 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12299
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12300 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12301 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12303 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12304 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12305 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12306 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12307 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12308 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12309 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12310 ULONG message = 0, id = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12311
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12312 if (window && signame && sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12313 {
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
12314 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
12315 window = _normalize_handle(window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12316
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12317 if ((message = _findsigmessage(signame)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12318 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12319 /* Handle special case of the menu item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12320 if (message == WM_COMMAND && window < (HWND)65536)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12321 {
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
12322 char buffer[16];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12323 HWND owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12324
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12325 _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
12326 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
12327
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
12328 /* 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
12329 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
12330
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12331 if (owner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12332 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12333 id = (ULONG)(uintptr_t)window;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12334 window = owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12335 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12336 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12337 _new_signal(message, window, id, sigfunc, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12338 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12339 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12342 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12343 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12344 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12345 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12346 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12347 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12348 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12349 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12350 ULONG message;
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 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12353 return;
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 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12356 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12357 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
12358 {
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
12359 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12360 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12361 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12362 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12363 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12364 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12365 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12366 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12367 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12368 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12369 tmp = Root;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12372 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12373 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12374 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12375 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12376 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12377 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12378 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12380 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12381 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12382 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12383 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12384 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12385 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12386 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12387 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12388
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12389 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12390 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12391 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
12392 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12393 if(prev)
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 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12396 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12397 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12398 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12399 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12400 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12401 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12402 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12403 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12404 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12405 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12406 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12407 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12408 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12409 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12410 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12411 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12412 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12414 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12415 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12416 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12417 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12418 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12419 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12420 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12421 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12422 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12423
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12424 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12425 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12426 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
12427 {
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
12428 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12429 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12430 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12431 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12432 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12433 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12434 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12437 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12438 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12439 }
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12442 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12443 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12444 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12445 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12446 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12447 }
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12448
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12449 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12450 * 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
12451 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12452 * 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
12453 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12454 * 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
12455 * 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
12456 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12457 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
12458 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12459 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12460 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
12461 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12462 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12463 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12464 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12465
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12466 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12467 * 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
12468 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12469 * 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
12470 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12471 * 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
12472 * 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
12473 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12474 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
12475 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12476 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12477 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
12478 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12479 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12480 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12481 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12482