annotate win/dw.c @ 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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 20 Nov 2012 20:42:06 +0000
parents 22225eb286e5
children 905f8632005b
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);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2744 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2745 else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2746 {
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 * 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
2749 * has a default click set
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2750 */
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2751 HWND tl = _toplevel_window( hWnd );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2752 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA );
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2753 if ( mycinfo && mycinfo->clickdefault )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2754 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2755 _click_default( mycinfo->clickdefault );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2756 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2757 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2758 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2759
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2760 /* 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
2761 * 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
2762 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2763 if (cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2764 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
2765 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
2766 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2767 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2768 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2769 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2770 if(cinfo->buddy)
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 long val;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2773
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
2774 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
2775
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
2776 _sntprintf(tmpbuf, 99, TEXT("%ld"), val);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2777 SetWindowText(hWnd, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2779 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2780 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2781 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2782 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2783 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2784 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2785 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2786 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2787 case WM_CTLCOLORDLG:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2789 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
2790 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
2791 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2792 int thisback = thiscinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2793
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2794 /* Handle foreground */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2795 if(thiscinfo->fore != DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2796 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2797 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
2798
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2799 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
2800 DW_GREEN_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2801 DW_BLUE_VALUE(fore)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2802 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2803 /* Handle background */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2804 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
2805 {
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2806 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
2807
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2808 if(parentcinfo && parentcinfo->back != -1)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2809 thisback = parentcinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2810 }
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2811 if(thisback == DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2812 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2813 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2814
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2815 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
2816
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2817 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
2818 return (LONG)(intptr_t)hbr;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2819 }
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2820 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
2821 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2822 int back = _internal_color(thisback);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2823
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2824 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
2825 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2826 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2827 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2828 DeleteObject(thiscinfo->hbrush);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2829 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
2830 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2831 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2832 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
2833 return (LONG)(intptr_t)thiscinfo->hbrush;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2834 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2835 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2836 #ifdef AEROGLASS
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2837 switch(msg)
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2838 {
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2839 case WM_CTLCOLORSTATIC:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2840 case WM_CTLCOLORBTN:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2841 case WM_CTLCOLORDLG:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2842 {
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2843
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2844 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
2845 (!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
2846 {
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
2847 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
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 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
2850 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
2851 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
2852 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
2853 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
2854 return (LONG)thiscinfo->hbrush;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2855 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2856 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2857 }
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 #endif
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2860 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2861 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2862 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2863 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2864
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
2865 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
2866 {
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2867 if(!pOldProc)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2868 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
2869 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
2870 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2871 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
2872 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2873
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2874 /* 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
2875 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
2876 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2877 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
2878
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2879 switch( msg )
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 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2882 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2883 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2884 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2885 break;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2886 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
2887 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
2888 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
2889 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
2890 int iItems, iTop, i;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2891 COLORREF c;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2892
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2893 /* 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
2894 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
2895 /* 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
2896 GetUpdateRect(hWnd, &rectUpd, FALSE);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2897 /* 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
2898 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
2899 /* number of displayed rows */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2900 iItems = ListView_GetCountPerPage(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2901 /* first visible row */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2902 iTop = ListView_GetTopIndex(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2903
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
2904 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
2905 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2906 /* 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
2907 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
2908 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2909 /* 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
2910 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
2911
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2912 if(c != DW_RGB_TRANSPARENT)
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 ListView_SetTextBkColor(hWnd, c);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2915 /* 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
2916 InvalidateRect(hWnd, &rectDestin, FALSE);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2917 /* ...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
2918 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
2919 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2920 }
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 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2924 case WM_LBUTTONDBLCLK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2925 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2926 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2927 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2928 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2929
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2930 if(LOWORD(mp1) == '\t')
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(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
2933 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2934 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2936 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2937 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2938
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2939 if(msg == WM_CHAR && (char)mp1 != '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2940 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2941
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2942 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2949 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2951 ListView_GetItem(hWnd, &lvi);
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
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 SignalHandler *tmp = Root;
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 while(tmp)
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 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
2960 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2961 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
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 /* 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
2964 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2965 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2966
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2967 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
2968 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2969 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2970 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2971 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2972 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2973 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2974 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2975 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2976 case WM_CONTEXTMENU:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2977 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2978 SignalHandler *tmp = Root;
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 while(tmp)
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 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
2983 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2984 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
2985 LONG x,y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2986 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2987 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2988 LVHITTESTINFO lhi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2989
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2990 dw_pointer_query_pos(&x, &y);
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 lhi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2993 lhi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2994
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2995 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
2996
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2997 iItem = ListView_HitTest(tmp->window, &lhi);
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3004 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3005
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3006 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3007 ListView_SetSelectionMark(tmp->window, iItem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3008 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3009
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3010 /* 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
3011 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3012 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3013
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3014 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
3015 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3016 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3017 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3018 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3019 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3020 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3021 break;
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
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3024 if(!continfo || !continfo->cinfo.pOldProc)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3025 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
3026 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
3029 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
3030 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3031 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
3032 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3033
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3034 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 switch( msg )
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 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
3039 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3040 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3041 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
3042 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
3043 if(ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3045 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
3046 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3047 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3049 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3050 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3051 break;
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
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3054 if(ret != TRUE)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3055 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3056 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
3057 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
3058 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
3059 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3060 return ret;
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3061 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3062
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3063 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3064 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3065 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3066
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3067 for(z=0;z<thisbox->count;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 if(thisbox->items[z].type == TYPEBOX)
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 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
3072 _changebox(tmp, percent, type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3073 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3074 else
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 if(type == DW_HORZ)
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(thisbox->items[z].hsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3079 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
3080 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3081 else
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 if(thisbox->items[z].vsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3084 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
3085 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3086 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3087 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3090 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
3091 {
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
3092 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
3093 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
3094
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 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
3096 ShowWindow(handle2, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3097
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3098 if(type == DW_HORZ)
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 int newx = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3101 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
3102 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
3103
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3104 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
3105
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3106 MoveWindow(handle1, 0, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3107 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3108
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3109 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
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 newx = x - newx - SPLITBAR_WIDTH;
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 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
3114 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3115
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3116 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
3117 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3118 else
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 int newy = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3121 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
3122 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
3123
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3124 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
3125
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3126 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
3127 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3128
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3129 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3130
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3131 newy = y - newy - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3132
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3133 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
3134 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3135
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3136 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
3137 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3138
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3139 ShowWindow(handle1, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3140 ShowWindow(handle2, SW_SHOW);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3141 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3142
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3143 /* 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
3144 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
3145 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3146 switch (msg)
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3147 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3148 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
3149 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
3150 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3151 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
3152 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
3153 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
3154 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
3155
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3156 /* 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
3157 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
3158 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
3159
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3160 /* 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
3161 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
3162 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
3163
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3164 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
3165 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3166 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
3167 si = &vsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3168 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3169
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3170 switch(which)
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 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
3173 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
3174 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3175 /*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
3176 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
3177 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
3178 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
3179 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
3180 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3181 /*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
3182 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
3183 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
3184 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
3185 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
3186 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3187 /*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
3188 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
3189 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
3190 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
3191 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
3192 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3193 /*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
3194 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
3195 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
3196 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
3197 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
3198 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3199 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3200
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3201 /* 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
3202 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
3203 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
3204 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
3205 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3206 break;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3207 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3208 return DefWindowProc(hwnd, msg, mp1, mp2);
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 /* 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
3212 LRESULT CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3214 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3215 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3216 case WM_ACTIVATE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3217 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3218 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3219
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3220 case WM_PAINT:
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 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3223 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
3224 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
3225 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
3226
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3227 BeginPaint(hwnd, &ps);
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 if((hdcPaint = GetDC(hwnd)) != NULL)
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 unsigned long cx, cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3232 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3233 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
3234
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3235 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
3236
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3237 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3238 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
3239 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3240 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
3241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3242 SelectObject(hdcPaint, oldBrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3243 DeleteObject(SelectObject(hdcPaint, oldPen));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3244 ReleaseDC(hwnd, hdcPaint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3245 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3246 EndPaint(hwnd, &ps);
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3249 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3250 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3251 SetCapture(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3252 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3253 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3254 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3255 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3256 if(GetCapture() == hwnd)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3257 ReleaseCapture();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3258 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3259 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3260 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3261 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3262 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
3263 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
3264 int start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3265
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3266 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3267 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3268 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3269 SetCursor(LoadCursor(NULL, IDC_SIZENS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3270
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3271 if(GetCapture() == hwnd && percent)
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 POINT point;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3274 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3275 static POINT lastpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3276
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3277 GetCursorPos(&point);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3278 GetWindowRect(hwnd, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3279
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3280 if(memcmp(&point, &lastpoint, sizeof(POINT)))
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(PtInRect(&rect, 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 int width = (rect.right - rect.left);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3285 int height = (rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3286
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3287 if(type == DW_HORZ)
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 start = point.x - rect.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3290 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
3291 *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
3292 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3293 else
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 start = point.y - rect.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3296 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
3297 *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
3298 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3299 _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
3300 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3301 memcpy(&lastpoint, &point, sizeof(POINT));
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3304 break;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3307 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
3308 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3309
5c66a108aa47 Fixed 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 /* 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
3311 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
3312 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3313 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3314 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3315 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3316 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3317 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3318 case WM_SETTEXT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3319 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3320 /* 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
3321 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
3322
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3323 InvalidateRgn(hwnd, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3324 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3325 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3326 case WM_PAINT:
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 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3329 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3330 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3331 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
3332 TCHAR tempbuf[1025] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3333 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3334 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
3335 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
3336
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3337 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
3338 GetWindowText(hwnd, tempbuf, 1024);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3339
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3340 hdcPaint = BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3341 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3342 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3343 rc.top = rc.left = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3344 rc.right = cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3345 rc.bottom = cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3346 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3347 if(hfont && oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3348 SelectObject(hdcPaint, oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3349 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3350 DeleteObject(hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3351 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3352 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3353 return FALSE;
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 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
3356 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3357
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
3358 #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
3359 /* 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
3360 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
3361 {
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
3362 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
3363 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
3364
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 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
3366 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
3367
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
3368 /* 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
3369 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
3370
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
3371 /* 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
3372 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
3373 || !_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
3374 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
3375
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 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
3377
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 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
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 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
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 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
3383 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
3384
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 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
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 /* 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
3388 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
3389 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
3390 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
3391 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
3392 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
3393
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 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
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 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
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 /* 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
3399 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
3400
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 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
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 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
3404 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
3405 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
3406 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
3407 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
3408
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 /* 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
3410 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
3411 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
3412
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3413 /* 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
3414 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
3415 _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
3416
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3417 /* 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
3418 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
3419 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
3420 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
3421
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 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
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 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
3425 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
3426
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 /* 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
3428 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
3429 {
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 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
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 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
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 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
3435 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
3436 {
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 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
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 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
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 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
3442 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
3443 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
3444 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
3445 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
3446 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
3447 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
3448 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
3449 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
3450 }
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
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 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
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 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
3455 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
3456 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3457
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3458
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 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
3460 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
3461 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
3462 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
3463 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
3464 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
3465
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 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
3467 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
3468
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 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
3470 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
3471
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 /* 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
3473 _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
3474 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
3475 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3476 }
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 /* 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
3480 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
3481 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
3482 _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
3483 }
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 _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
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 }
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 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
3489 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
3490 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3491 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
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
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 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
3495 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
3496 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
3497 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3498 #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
3499
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
3500 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503
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
3504 LRESULT CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3506 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
3507 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
3508 int retval = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3509
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3510 if ( !cinfo )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3511 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3513 /* 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
3514 * window procedure because if a signal
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3515 * handler attached here destroys this
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3516 * window it will then be invalid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3517 */
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3518 pOldProc = cinfo->pOldProc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3520 switch(msg)
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 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3523 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3524 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3525 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3526 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3527 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3528 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
3529 return _colorwndproc(hwnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3530 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3531 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3532 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3533 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3534 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3535 SignalHandler *tmp = Root;
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3538 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3539 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3540 if(tmp->message == WM_COMMAND)
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 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
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 /* 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
3545 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3546 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3547 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
3548
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3549 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3550 in_checkbox_handler = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3551
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
3552 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3553
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3554 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3555 in_checkbox_handler = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3556 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3557 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3558 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3559 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3560 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3561 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3562 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3563 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3564 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3565 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3566 /* 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
3567 * 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
3568 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3569 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
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 SignalHandler *tmp = Root;
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3574 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3575 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3576 if(tmp->message == WM_COMMAND)
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 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
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 /* 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
3581 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3582 {
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
3583 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3584 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3585 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3586 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3587 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3588 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3589 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3590 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3591 if(LOWORD(mp1) == '\t')
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(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
3594 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3595 else
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_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3597 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3598 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3599 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3600 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3601 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3602 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
3603 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3604 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
3605 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3606 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3607 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3608
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
3609 /* 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
3610 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
3611 _dw_redraw(0, FALSE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3612 if ( !pOldProc )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3613 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3614 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
3615 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3616
5c66a108aa47 Fixed 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 /* 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
3618 * 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
3619 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3620 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
3621 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3622 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3623 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
3624
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3625 if(array && array[pageid])
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 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
3628
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3629 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3630 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3631 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
3632 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
3633 if(box && box->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3634 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3635 ShowWindow(box->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3636 _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
3637 ShowWindow(box->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3638 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3639
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3640 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3641 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643
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
3644 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
3645 {
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
3646 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
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 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
3649 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
3650 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
3651
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 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
3653 if(text)
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3654 {
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3655 /* 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
3656 * 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
3657 */
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3658 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
3659 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
3660 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
3661
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3662 /* 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
3663 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
3664 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
3665 }
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
3666
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
3667 #ifndef GDIPLUS
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3668 /* 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
3669 */
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3670 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
3671 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3672 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
3673 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
3674
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3675 *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
3676 *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
3677
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3678 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
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 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
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
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3683 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
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 /* 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
3686 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
3687 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3688 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
3689 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
3690 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3691 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
3692 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
3693 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3694 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
3695 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3696 *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
3697 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
3698 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3699 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
3700 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3701 *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
3702 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
3703 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3704 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
3705 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3706 *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
3707 windowtype = BS_BITMAP;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3708 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3709 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
3710 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3711 else
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 /* 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
3714 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
3715 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
3716 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3717 *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
3718 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
3719 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3720 else
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 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
3723 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
3724 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
3725 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3726 *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
3727 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
3728 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3729 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3730 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
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 return windowtype;
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3733 }
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
3734 #endif
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3735
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3736 /* 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
3737 void _init_thread(void)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3738 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3739 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
3740 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
3741 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3742 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
3743 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
3744 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
3745
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3746 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
3747 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
3748 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
3749 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
3750 #endif
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(_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
3752 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
3753 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
3754 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3755 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3756
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3763 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3765 WNDCLASS wc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3766 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3767 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
3768 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
3769 #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
3770 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
3771 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3772
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3773 /* 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
3774 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
3775 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3776 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
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 /* 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
3779 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
3780 pos = strrchr(argv[0], '/');
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3781
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3782 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
3783 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
3784 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3785 /* 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
3786 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
3787 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
3788
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3789 /* Initialize our thread local storage */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3790 _foreground = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3791 _background = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3792 _hPen = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3793 _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
3794 #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
3795 _gpPen = TlsAlloc();
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3796 _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
3797 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3798
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3799 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3800 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
3801
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3802 InitCommonControlsEx(&icc);
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 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
3805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3806 /* Register the generic Dynamic Windows class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3807 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3808 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3809 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3810 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3811 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3812 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3813 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3814 wc.lpszClassName = ClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3815
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3816 RegisterClass(&wc);
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 /* Register the splitbar control */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3819 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3820 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
3821 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3822 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3823 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3824 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3825 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3826 wc.lpszClassName = SplitbarClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3827
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3828 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3829
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3830 /* Register the scroller control */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3831 memset(&wc, 0, sizeof(WNDCLASS));
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3832 wc.style = CS_DBLCLKS;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3833 wc.lpfnWndProc = (WNDPROC)_scrollwndproc;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3834 wc.cbClsExtra = 0;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3835 wc.cbWndExtra = 32;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3836 wc.hbrBackground = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3837 wc.lpszMenuName = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3838 wc.lpszClassName = ScrollClassName;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3840 RegisterClass(&wc);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3841
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3842 /* 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
3843 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3844 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3845 wc.lpfnWndProc = (WNDPROC)_framewndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3846 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3847 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3848 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3849 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3850 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3851 wc.lpszClassName = FRAMECLASSNAME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3853 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3854
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
3855 /* 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
3856 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
3857 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
3858 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
3859 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
3860 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
3861 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
3862 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
3863 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
3864 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
3865
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 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
3867
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3868 #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
3869 /* Register HTML renderer class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3870 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3871 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3872 wc.lpszClassName = BrowserClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3873 wc.style = CS_HREDRAW|CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3874 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
3875 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3876
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3877 /* 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
3878 for(z=0;z<18;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3879 _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
3880
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3881 /* 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
3882 * 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
3883 * of Windows.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3884 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3885 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3886 wc.style = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3887 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3888 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3889 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3890 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3891 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3892 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3893 wc.lpszClassName = ObjectClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3894
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3895 RegisterClass(&wc);
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 /* 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
3898 * 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
3899 * 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
3900 * 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
3901 * packed into their correct parent.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3902 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3903
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
3904 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
3905 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3906
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3907 if(!DW_HWND_OBJECT)
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 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
3910 exit(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3911 }
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
3912
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
3913 /* 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
3914 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
3915 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
3916
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 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
3918
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
3919 /* 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
3920 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
3921
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3922 /* 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
3923 dwVersion = GetVersion();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3924 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3926 /* Initialize Security for named events and memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3927 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3928 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3929
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3930 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
3931
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3932 /*
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3933 * 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
3934 */
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3935 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
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 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
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 else
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3940 {
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
3941 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
3942 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3943
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3944 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3945 /* Setup GDI+ */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3946 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
3947 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
3948 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
3949 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
3950 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
3951 #endif
1628
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3952
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3953 /* 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
3954 _init_thread();
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3955
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3956 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
3957 _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
3958 #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
3959 /* 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
3960 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
3961 {
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3962 _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
3963 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
3964 _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
3965 _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
3966 _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
3967 _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
3968 _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
3969 _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
3970 _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
3971 }
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 /* 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
3973 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
3974 {
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 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
3976 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
3977 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3978 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3979 #ifdef RICHEDIT
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3980 /* 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
3981 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
3982 hrichedit = LoadLibrary("riched32");
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3983 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3984 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
3987 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
3988
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 * 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
3991 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3992 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3994 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3995
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3996 _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
3997 /* 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
3998 _dw_redraw(0, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3999
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4000 /* 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
4001 _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
4002
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4003 /* 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
4004 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
4005 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4006 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
4007 _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
4008 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4009 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4010 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4011 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4012 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4013 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4017 * 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
4018 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4019 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
4020 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4021 _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
4022 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4023
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4024 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4025 * 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
4026 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4027 * 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
4028 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4029 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
4030 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4031 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4032 double start = (double)clock();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4033
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4034 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
4035 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4036 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
4037 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4038 GetMessage(&msg, NULL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4039 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
4040 _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
4041 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4042 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4043 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4044 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4045 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4046 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4047 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4048 Sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4049 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4050 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4051
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4052 /*
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
4053 * 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
4054 */
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 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
4056 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4057 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4058
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4059 _dwtid = dw_thread_id();
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 if(GetMessage(&msg, NULL, 0, 0))
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(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4064 _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
4065 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4066 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4067 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4068 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4069 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4070 }
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
4071 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4072
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4079 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4081 free(ptr);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4089 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4091 DWDialog *tmp = malloc(sizeof(DWDialog));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4092
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4093 tmp->eve = dw_event_new();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4094 dw_event_reset(tmp->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4095 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4096 tmp->done = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4097 tmp->result = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4109 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4111 dialog->result = result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4112 dw_event_post(dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4113 dialog->done = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4114 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4123 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4125 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4126 void *tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4127
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4128 while (GetMessage(&msg,NULL,0,0))
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 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
4131 _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
4132 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4133 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4134 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4135 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4136 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4137 if(dialog->done)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4138 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4139 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4140 dw_event_close(&dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4141 tmp = dialog->result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4142 free(dialog);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4143 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 /*
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
4147 * 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
4148 * 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
4149 * 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
4150 * ...: 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
4151 */
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 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
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 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
4155 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
4156
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4157 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
4158 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
4159 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
4160
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4161 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
4162 }
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4163
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 389
diff changeset
4171 int API dw_messagebox(char *title, int flags, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4173 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
4174 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4175 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4176
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4177 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
4178 vsnprintf(outbuf, 1024, format, args);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4179 va_end(args);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4180
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4181 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
4182 if(rc == IDOK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4183 return DW_MB_RETURN_OK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4184 else if(rc == IDYES)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4185 return DW_MB_RETURN_YES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4186 else if(rc == IDNO)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4187 return DW_MB_RETURN_NO;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4188 else if(rc == IDCANCEL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4189 return DW_MB_RETURN_CANCEL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4190 else return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 /*
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
4194 * 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
4195 * 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
4196 * 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
4197 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4198 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
4199 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4200 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
4201 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4202
5c66a108aa47 Fixed 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 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4204 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4205 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4206 * 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
4207 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4208 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
4209 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4210 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
4211 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4212
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 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4215 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4216 * 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
4217 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4218 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
4219 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4220 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
4221 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4222
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4223 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4228 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 {
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
4230 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
4231 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
4232
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 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
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 /* 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
4236 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
4237 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
4238
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4239 rc = ShowWindow(handle, SW_SHOW);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4240 SetFocus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4241 _initial_focus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4242 return rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4246 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4250 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4252 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4260 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 {
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4262 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
4263 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
4264
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4265 /* 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
4266 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
4267 {
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4268 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
4269 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
4270
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4271 _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
4272 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
4273
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4274 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
4275 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
4276 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
4277 }
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4278
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4279 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
4280 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
4281
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
4282 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
4283 _free_menu_data(menu);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4284
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
4285 /* 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
4286 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
4287 {
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
4288 dw_box_unpack(handle);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4289 _free_window_memory(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4290 EnumChildWindows(handle, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4291 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4292 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4293 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294
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
4295 /* 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
4296 * 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
4297 * 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
4298 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4299 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
4300 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4301 Box *mybox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4302
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4303 if(mybox)
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 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4306 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4307
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4308 GetClientRect(handle, &rect);
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 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
4311 _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
4312 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
4313 }
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
4314 }
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
4315
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4322 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4324 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
4325 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4326
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4327 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
4328 {
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4329 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
4330 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
4331 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
4332
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4333 /* 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
4334 if(myFontName)
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4335 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
4336 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
4337 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
4338
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4339 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
4340 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
4341 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
4342 lf.lfWidth = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4343 lf.lfEscapement = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4344 lf.lfOrientation = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4345 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
4346 lf.lfUnderline = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4347 lf.lfStrikeOut = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4348 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
4349 lf.lfCharSet = DEFAULT_CHARSET;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4350 lf.lfOutPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4351 lf.lfClipPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4352 lf.lfQuality = DEFAULT_QUALITY;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4353 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
4354 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
4355 *Italic = 0;
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4356 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
4357 *Bold = 0;
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4358 _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
4359 free(myFontName);
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4360 return lf;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4361 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4362
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
4363 /* 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
4364 * 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
4365 */
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 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
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 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
4369 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
4370 }
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4371
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4372 /* 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
4373 * 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
4374 */
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4375 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
4376 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4377 HFONT hfont = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4378
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4379 if(fontname != DefaultFont && fontname[0])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4380 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4381 LOGFONT lf = _get_logfont(hdc, fontname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4382 hfont = CreateFontIndirect(&lf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4383 }
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
4384 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
4385 hfont = _DupFontHandle(_DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4386 if(!hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4387 hfont = GetStockObject(DEFAULT_GUI_FONT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4388 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4391 /* 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
4392 * 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
4393 */
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4394 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
4395 {
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4396 HDC hdc = GetDC(handle);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4397 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
4398 ReleaseDC(handle, hdc);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4399 return hfont;
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4400 }
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4401
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 /*
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
4403 * 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
4404 * 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
4405 * 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
4406 */
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 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
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 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
4410
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
4411 _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
4412 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
4413 {
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 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
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 }
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
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
4418 /* 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
4419 * 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
4420 */
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 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
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 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
4424 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
4425
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 /* 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
4427 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
4428 {
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(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
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 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
4432 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
4433
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 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
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 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
4437 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
4438 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4439 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4440 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4441 return 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
4442 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4443
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4444 /* 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
4445 * 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
4446 *
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
4447 * 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
4448 * 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
4449 * 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
4450 * 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
4451 * 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
4452 * 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
4453 * 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
4454 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4455 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
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 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
4458 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
4459 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
4460 HBITMAP hbm = 0;
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4461 HICON hic = 0;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4462 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
4463
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
4464 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
4465
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4466 /* 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
4467 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
4468 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
4469 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
4470 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
4471
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4472 /* 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
4473 if(hic)
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4474 {
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4475 if(GetIconInfo(hic, &ii))
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4476 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
4477 }
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4478
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4479 /* 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
4480 if(!hbm)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4481 {
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4482 /* 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
4483 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
4484 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
4485 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
4486 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
4487 }
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4488
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
4489 /* 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
4490 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
4491 {
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4492 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
4493
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4494 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
4495 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
4496 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
4497 }
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4498 else
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4499 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4500 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
4501
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4502 /* 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
4503 * 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
4504 */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4505 if(buf)
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 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
4509 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
4510 _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
4511 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
4512 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
4513 }
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4514 }
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
4515
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
4516 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4517 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
4518 {
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
4519 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
4520 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
4521 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
4522 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
4523 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
4524 }
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
4525 /* 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
4526 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
4527 _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
4528 _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
4529 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4530 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
4531 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
4532 {
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 /* 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
4534 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
4535 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
4536 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4537 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
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 /* 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
4540 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
4541 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
4542 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4543 }
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 /* Spinbuttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4545 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
4546 {
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
4547 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
4548 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
4549 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
4550 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4551 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4552 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4553 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
4554 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4555 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
4556 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
4557
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4558 if(imlist)
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4559 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
4560
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4561 /* 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
4562 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
4563 minsize = 20;
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4564 else
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4565 {
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4566 thiswidth += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4567 thisheight += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4568 }
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4569
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4570 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
4571 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
4572 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
4573 thisheight = minsize;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4574 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4575 #endif
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4576 /* Listbox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4577 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
4578 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4579 char buf[1025] = {0};
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4580 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
4581 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
4582
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4583 thisheight = 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 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
4586 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4587 int height, width = 0;
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 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
4590
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4591 if(strlen(buf))
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4592 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
4593 else
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, testtext, NULL, &height);
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4595
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4596 width += basicwidth;
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 if(width > thiswidth)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4599 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
4600 thisheight += height;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4601 }
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4602
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4603 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
4604 thiswidth = _DW_SCROLLED_MIN_WIDTH;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4605 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
4606 thisheight = _DW_SCROLLED_MIN_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4607 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
4608 thisheight = _DW_SCROLLED_MAX_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4609 }
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
4610 /* 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
4611 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
4612 _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
4613 {
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
4614 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
4615 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
4616 {
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 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
4618 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
4619 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
4620 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
4621
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 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
4623 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
4624 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
4625 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
4626 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
4627
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 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
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 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
4631 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
4632 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
4633 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
4634
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
4635 /* MLE */
1581
a80ec948c3eb Fixed a MinGW warning and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1570
diff changeset
4636 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
4637 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4638 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
4639 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
4640 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
4641 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
4642 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
4643 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
4644
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 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
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 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
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 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
4650 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
4651 }
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 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
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 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
4655 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
4656 }
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 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
4658 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
4659 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4660
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4661 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
4662 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
4663 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
4664 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
4665 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
4666 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
4667 }
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
4668 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
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 /* 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
4671 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
4672 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
4673 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
4674 }
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 }
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4676 /* Container */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4677 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
4678 {
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4679 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
4680
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4681 thiswidth = LOWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4682 thisheight = HIWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4683
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4684 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
4685 thiswidth = _DW_SCROLLED_MAX_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4686 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
4687 thiswidth = _DW_SCROLLED_MIN_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4688 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
4689 thisheight = _DW_SCROLLED_MIN_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4690 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
4691 thisheight = _DW_SCROLLED_MAX_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4692 }
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4693 /* Tree */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4694 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
4695 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
4696 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
4697 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
4698 }
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4699 /* Buttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4700 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
4701 {
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
4702 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
4703
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
4704 /* 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
4705 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
4706 {
1431
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4707 extrawidth = 5;
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4708 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
4709 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4710 /* 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
4711 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
4712 {
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
4713 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
4714 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
4715 }
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
4716 /* 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
4717 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
4718 {
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 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
4720 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
4721 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4722 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4723 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
4724 {
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
4725 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
4726 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
4727 }
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
4728
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
4729 /* 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
4730 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
4731 *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
4732 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
4733 *height = thisheight + extraheight;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4734
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4735 /* Free temporary bitmaps */
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4736 if(ii.hbmColor)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4737 DeleteObject(ii.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4738 if(ii.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4739 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
4740 }
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
4741
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
4742 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4748 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 {
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4750 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
4751 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
4752 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
4753
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4754 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
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 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
4757 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
4758 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4759 /* groupbox */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4760 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
4761 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
4762 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4763 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
4764 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4765 }
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4766
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4767 /* 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
4768 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
4769 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
4770
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
4771 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
4772 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4773 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
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 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
4776 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
4777 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
4778 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
4779 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4780 else
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 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
4783 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
4784
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
4785 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
4786
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4787 cinfo->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
4788 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
4789 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4790 }
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
4791 /* 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
4792 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
4793 {
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 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
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 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
4797 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
4798 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
4799
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4800 /* 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
4801 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
4802 {
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
4803 _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
4804 /* 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
4805 _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
4806 }
1411
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4807 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
4808 }
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_UNKNOWN;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4812 /* 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
4813 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4814 * currfont: current font
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4815 * Returns:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4816 * 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
4817 */
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4818 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
4819 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4820 CHOOSEFONT cf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4821 LOGFONT lf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4822 char *str = NULL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4823 char *bold = "";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4824 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
4825
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4826 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
4827 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
4828
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4829 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
4830 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
4831 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
4832
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4833 if(ChooseFont(&cf))
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4834 {
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
4835 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
4836 if ( str )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4837 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4838 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
4839 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
4840
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4841 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
4842 bold = " Bold";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4843 if ( lf.lfItalic )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4844 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
4845 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
4846 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
4847 _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
4848 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4849 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4850 return str;
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 /*
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4854 * 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
4855 * Parameters:
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4856 * handle: The window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4857 * 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
4858 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4859 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
4860 {
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4861 HFONT oldfont = NULL;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4862 char *str = NULL;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4863 char *bold = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4864 char *italic = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4865 LOGFONT lf = { 0 };
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4866 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
4867 TCHAR tmpbuf[100] = {0};
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4868
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4869 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
4870 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
4871 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4872 /* groupbox */
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4873 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
4874 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
4875 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4876 handle = thisbox->grouphwnd;
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 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4879 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
4880 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
4881 {
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
4882 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
4883 if ( str )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4884 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4885 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
4886 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
4887
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4888 if ( lf.lfWeight > FW_MEDIUM )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4889 bold = " Bold";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4890 if ( lf.lfItalic )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4891 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
4892 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
4893 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
4894 _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
4895 }
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4896 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4897 if ( oldfont )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4898 DeleteObject( oldfont );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4899 return str;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4900 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4901
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4902 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 * 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
4906 * 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
4907 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4909 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4911 ColorInfo *cinfo;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4912 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
4913 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4914
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4915 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4918
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4919 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
4920 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
4921 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
4922 cinfo->back = back = _internal_color(back);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4923
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4924 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
4925 DW_GREEN_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4926 DW_BLUE_VALUE(fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4927 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
4928 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4929 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4930 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
4931 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4932 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4933 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4934 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4935 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4936 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
4937 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4938 /* groupbox */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4939 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
4940 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
4941 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4942 thisbox->cinfo.fore = fore;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4943 thisbox->cinfo.back = back;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4944 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4945 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4947 if(cinfo)
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 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4950 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4951 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4952 else
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 cinfo = calloc(1, sizeof(ColorInfo));
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->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4957 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4958
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4959 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4960 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4961 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4962 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4963 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4964 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4972 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4974 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4982 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4984 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4990 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4992 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4996 * 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
4997 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4998 * 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
4999 * 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
5000 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
5001 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
5002 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5003 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
5004
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5005 if(!pointertype)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5006 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
5007 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5008 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5009 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
5010 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5011 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5012 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5013
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5014 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 * 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
5019 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5021 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5023 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5024 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
5025 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
5026 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5027 MARGINS mar = {-1};
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5028
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5029 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
5030 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
5031 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5032
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5033 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
5034 newbox->vsize = newbox->hsize = SIZEEXPAND;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5035 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5036
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5037 if(!(flStyle & WS_CAPTION))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5038 flStyle |= WS_POPUPWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5039
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5040 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
5041 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
5042 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5043 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
5044 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5045 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5046 else
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 flStyleEx |= WS_EX_TOOLWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5049
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5050 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
5051 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5052 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5053 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
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 if(hwndOwner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5056 SetParent(hwndframe, hwndOwner);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5057
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5058 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5059 /* 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
5060 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
5061 {
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5062 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
5063 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5064 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5065 #endif
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5066
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5067 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 * 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
5073 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5076 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5078 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5079 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5080
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5081 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5082 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5083 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5084 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5085 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5086
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5087 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5088 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5089 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
5090 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5091 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5092 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5093 DWInstance,
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5096 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5097 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5098
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5099 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5100 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5104 * 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
5105 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5106 * 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
5107 * 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
5108 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5109 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
5110 {
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5111 ColorInfo *cinfo = calloc(sizeof(ColorInfo), 1);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5112 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
5113 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
5114 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
5115
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5116 cinfo->fore = cinfo->back = -1;
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 hwndframe = CreateWindow(ScrollClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5119 NULL,
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5120 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
5121 0,0,0,0,
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5122 DW_HWND_OBJECT,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5123 NULL,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5124 DWInstance,
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
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5127 cinfo->buddy = box;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5128 cinfo->combo = tmpbox;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5129 SetParent(tmpbox, hwndframe);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5130 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)cinfo);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5131 return hwndframe;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5132 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5133
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5134 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5135 * 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
5136 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5137 * 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
5138 * 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
5139 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5140 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
5141 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5142 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
5143 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
5144
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5145 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
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 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
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
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5150 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
5151 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
5152
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5153 /* 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
5154 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
5155 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5156 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
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 si.nPos;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5159 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5160
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5161 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5162 * 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
5163 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5164 * 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
5165 * 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
5166 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5167 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
5168 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5169 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
5170 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
5171
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5172 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
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 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
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
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5177 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
5178 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
5179
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5180 /* 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
5181 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
5182 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5183 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
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 si.nMax;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5186 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5187 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 * 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
5190 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5194 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5196 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5197 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5198
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5199 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5200 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5201 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5202 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5203
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5204 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5205 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5206 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
5207 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5208 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5209 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5210 DWInstance,
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
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5213 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5214 UTF8toWide(title),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5215 WS_CHILD | BS_GROUPBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5216 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
5217 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5218 hwndframe,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5219 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5220 DWInstance,
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5223 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
5224 dw_window_set_font(hwndframe, DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5225 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5229 * 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
5230 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5231 * 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
5232 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5233 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
5234 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5235 CLIENTCREATESTRUCT ccs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5236 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5237
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5238 ccs.hWindowMenu = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5239 ccs.idFirstChild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5240
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5241 hwndframe = CreateWindow(TEXT("MDICLIENT"),
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5242 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5243 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
5244 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5245 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
5246 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5247 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5248 &ccs);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5249 return hwndframe;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5250 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5251
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5252 /*
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5253 * 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
5254 * Parameters:
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5255 * 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
5256 */
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5257 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
5258 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5259 #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
5260 return CreateWindow(BrowserClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5261 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5262 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
5263 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5264 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
5265 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5266 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5267 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
5268 #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
5269 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
5270 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
5271 #endif
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5272 }
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5273
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5274 #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
5275 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
5276 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
5277 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
5278 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5279
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5280 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5281 * 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
5282 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5283 * 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
5284 * 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
5285 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5286 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
5287 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5288 #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
5289 _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
5290 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5291 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5292
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 * 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
5295 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5296 * 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
5297 * 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
5298 * be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5299 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5300 * 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
5301 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5302 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
5303 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5304 #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
5305 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
5306 #else
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_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5308 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5309 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5310
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 * 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
5313 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5314 * 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
5315 * 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
5316 * 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
5317 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5318 * 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
5319 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5320 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
5321 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5322 #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
5323 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
5324 #else
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_ERROR_GENERAL;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5326 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5327 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5328
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5329 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 * 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
5332 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5334 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5336 return CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5337 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
5338 SS_BITMAP | SS_CENTERIMAGE | WS_VISIBLE |
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5339 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
5340 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5341 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
5342 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5343 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5344 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5353 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5355 ULONG flags = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5356 HWND tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5357 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
5358 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5359
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5360 if(!top)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5361 flags = TCS_BOTTOM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5362
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5363 tmp = CreateWindow(WC_TABCONTROL,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5364 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5365 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
5366 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5367 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
5368 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5369 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5370 NULL);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5371 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
5372 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
5373 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
5374 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
5375 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5376 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5385 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5387 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5395 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5397 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
5398 MENUINFO mi;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5399
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5400 tmp = (HMENUI)CreateMenu();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5401
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5402 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
5403 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
5404 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
5405
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 SetMenuInfo( (HMENU)tmp, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5407
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5408 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
5409
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5410 SetMenu(location, (HMENU)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5411 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5419 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5421 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5422 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5423 HMENU mymenu = (HMENU)*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 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5426 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
5427 if(IsMenu(mymenu))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5428 DestroyMenu(mymenu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5429 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431
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
5432 /* 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
5433 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
5434 {
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
5435 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
5436
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5437 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
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 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
5440 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
5441 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
5442 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5443 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
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5449 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 * 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
5454 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5457 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
5458 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5459 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5460 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
5461 char buffer[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5462 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
5463 char *menutitle = title;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5464
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5465 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5466 * 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
5467 * for the menubar
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5468 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5469 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5470 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
5471
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5472 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5473 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5474 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
5475
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5476 /* 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
5477 if (title)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5478 {
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
5479 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
5480
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 strcpy(tmp, title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5482
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5483 while(*tmp)
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 if(*tmp == '~')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5486 *tmp = '&';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5487 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5488 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5489 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5490
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
5491 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
5492 {
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
5493 /* 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
5494 * 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
5495 */
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 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
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 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
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 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
5501 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
5502
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 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
5504 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
5505 }
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 /* 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
5507 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
5508 {
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 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
5510
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
5511 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
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 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
5514 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
5515 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
5516 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5517 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
5518 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
5519 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5520 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
5521 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5522 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5523 mii.fType = MFT_SEPARATOR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5524
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5525 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5526 * Handle flags
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 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
5529 if ( is_checked )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5530 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5531 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5532 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5533 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
5534 if ( is_disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5535 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5536 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5537 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5538
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5539 mii.wID = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5540 if (IsMenu((HMENU)submenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5541 mii.hSubMenu = (HMENU)submenu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5542 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5543 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
5544 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
5545 mii.cch = (UINT)_tcslen(mii.dwTypeData);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5546
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5547 InsertMenuItem(mymenu, 65535, TRUE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5548
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
5549 _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
5550 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
5551 _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
5552 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
5553 _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
5554 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
5555 _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
5556 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
5557
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
5558 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
5559 {
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 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
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 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
5563 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
5564 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
5565
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5566 SetMenuInfo( (HMENU)submenu, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5567 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5568
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5569 if (IsWindow(menux) && !IsMenu((HMENU)menux))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5570 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
5571 return (HWND)(uintptr_t)id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 * 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
5576 * Deprecated: use dw_menu_item_set_state()
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5578 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5582 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5584 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
5585 HMENU mymenu = (HMENU)menux;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5586 char buffer[30];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5587
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5588 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5589 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
5590
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5591 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5592 * 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
5593 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5594 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5595 GetMenuItemInfo( mymenu, id, FALSE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5596
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5597 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5598 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5599 if (check)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5600 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5601 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5602 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5603 SetMenuItemInfo( mymenu, id, FALSE, &mii );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5604 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5605 * Keep our internal state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5606 */
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
5607 _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
5608 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
5609 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5610
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 * Sets the state of a menu item.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5613 * Parameters:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5614 * menu: The handle to the existing menu.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5615 * id: Menuitem id.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5616 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5617 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5618 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5619 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
5620 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5621 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5622 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
5623 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
5624 int check;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5625 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
5626
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5627 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
5628 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
5629
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
5630 _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
5631 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
5632 _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
5633 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
5634
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5635 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5636
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5637 mii.cbSize = sizeof(MENUITEMINFO);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5638 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5639 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
5640 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5641 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5642 * 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
5643 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5644 if ( state & DW_MIS_CHECKED )
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 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5647 check = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5648 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5649 else
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 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5652 check = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5653 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5654 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5655 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5656 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5657 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5658 * ...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
5659 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5660 if ( check )
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 mii.fState |= MFS_CHECKED;
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5665 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5666 mii.fState |= MFS_UNCHECKED;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5669 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
5670 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5671 if ( 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 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5674 disabled = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5675 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5676 else
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 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5679 disabled = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5680 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5681 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5682 else
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 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5685 * ...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
5686 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5687 if ( disabled )
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 mii.fState |= MFS_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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5692 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5693 mii.fState |= MFS_ENABLED;
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 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5696 SetMenuItemInfo( mymenu, id, FALSE, &mii );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5697 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5698 * Keep our internal checked state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5699 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5700 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
5701 dw_window_set_data( DW_HWND_OBJECT, buffer2, DW_INT_TO_POINTER(disabled) );
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5704 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5705 * Deletes the menu item specified
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5706 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5707 * 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
5708 * 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
5709 * Returns:
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5710 * 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
5711 */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5712 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
5713 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5714 HMENU mymenu = (HMENU)menux;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5715
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5716 if ( IsWindow(menux) && !IsMenu(mymenu) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5717 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
5718
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
5719 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
5720 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
5721
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
5722 /* 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
5723 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
5724 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
5725
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5726 /* 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
5727 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
5728 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
5729 return DW_ERROR_NONE;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5730 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5731
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5740 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5742 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5743 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5744 HMENU mymenu = (HMENU)*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 if(IsWindow(*menu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5747 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
5748
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5749 popup = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5750 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
5751 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
5752 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754
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 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5762 HWND API dw_container_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5764 HWND tmp = CreateWindow(WC_LISTVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5765 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5766 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5767 (multi ? 0 : LVS_SINGLESEL) |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5768 LVS_REPORT | LVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5769 LVS_SHAREIMAGELISTS | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5770 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
5771 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5772 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
5773 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5774 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5775 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5776 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5777
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5778 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5781 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5782 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5783
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5784 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5785 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
5786 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
5787
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5788 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5789 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
5790 /* 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
5791 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
5792 {
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 /* 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
5794 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
5795 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5796 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5800 * 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
5801 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5802 * 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
5803 * 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
5804 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5805 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
5806 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5807 HWND tmp = CreateWindow(WC_TREEVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5808 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5809 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5810 TVS_HASLINES | TVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5811 TVS_HASBUTTONS | TVS_LINESATROOT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5812 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
5813 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5814 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
5815 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5816 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5817 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5818 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5819 TreeView_SetItemHeight(tmp, 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5820
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5821 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5824 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5825 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5826
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5827 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5828 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
5829 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
5830
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5831 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5832 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5833 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
5834 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5835
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5836 /*
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
5837 * 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
5838 * 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
5839 * 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
5840 * 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
5841 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5842 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
5843 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5844 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5846 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5847 if(x && y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5848 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5849 *x = ptl.x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5850 *y = ptl.y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5851 }
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
5852 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5853
5c66a108aa47 Fixed 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 * 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
5856 * 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
5857 * 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
5858 * 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
5859 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5860 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
5861 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5862 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
5863 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5864
5c66a108aa47 Fixed 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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 * 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
5869 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5871 HWND API dw_text_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5873 HWND tmp = CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5874 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
5875 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
5876 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
5877 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5878 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
5879 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5880 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5881 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
5882 #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
5883 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
5884
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 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
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->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
5888 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
5889 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5890 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
5891 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
5892 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5896 * 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
5897 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5898 * 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
5899 * 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
5900 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5901 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
5902 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5903 HWND tmp = CreateWindow(StatusbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5904 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
5905 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
5906 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5907 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
5908 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5909 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5910 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5911 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5912 return tmp;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5913 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5914
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5915 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 * 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
5918 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5920 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 {
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
5922
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5923 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
5924 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5925 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5926 WS_VISIBLE | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5927 WS_VSCROLL | ES_MULTILINE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5928 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5929 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
5930 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5931 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
5932 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5933 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5934 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5935 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5936
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5937 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5940 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5941 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5942
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5943 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5944 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
5945 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
5946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5947 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5948 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5949 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 * 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
5956 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5958 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5960 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
5961 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5962 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5963 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5964 WS_BORDER | ES_AUTOHSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5965 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
5966 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5967 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
5968 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5969 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5970 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5971 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5972
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5973 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5976 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5977 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5978 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 /*
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
5982 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 * 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
5985 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5987 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5989 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
5990 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5991 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5992 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5993 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5994 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
5995 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5996 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
5997 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5998 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5999 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6000 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6001
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6002 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6005 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6006 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6007 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009
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
6010 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
6011 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6012 ColorInfo *cinfo = (ColorInfo *)lp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6013
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6014 if(cinfo)
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 cinfo->buddy = handle;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6017 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6018 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6019 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6020 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
6021 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6022
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 * 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
6027 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6029 HWND API dw_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6031 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6032 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6033 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6034 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
6035 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6036 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
6037 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6038 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6039 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6040 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6041 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6042
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6043 if(!cinfo || !cinfo2)
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)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6046 free(cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6047 if(cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6048 free(cinfo2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6049 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6050 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6051 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6052
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6053 cinfo2->fore = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6054 cinfo2->back = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6055 cinfo2->combo = cinfo->combo = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6056 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
6057 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
6058
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6059 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6060 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
6061 SetWindowText(tmp, UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6062 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 * 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
6069 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6071 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6073 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
6074
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6075 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6076 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
6077 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
6078 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
6079 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
6080 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
6081 (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
6082 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6083 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6084 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6085 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
6086
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6087 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
6088 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
6089 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6092 #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
6093 /* 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
6094 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
6095 {
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 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
6097 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
6098 {
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 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
6100 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
6101
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 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
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(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
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 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
6107 /* 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
6108 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
6109
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6110 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
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 }
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 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
6114 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
6115 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6116 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6117
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6118 /* 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
6119 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
6120 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6121 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
6122 HIMAGELIST imlist, dimlist;
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6123 BITMAP bmi = { 0 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6124 TBBUTTON tbButtons[] = {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6125 { 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
6126 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6127
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6128 /* 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
6129 if(hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6130 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6131 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
6132 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
6133 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
6134 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
6135 _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
6136 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
6137 DeleteObject(hbitmap);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6138 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6139 else if(icon)
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 ICONINFO iconinfo;
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 GetIconInfo(icon, &iconinfo);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6144 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
6145 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
6146 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
6147 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
6148 _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
6149 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
6150 DeleteObject(iconinfo.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6151 DeleteObject(iconinfo.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6152 DestroyIcon(icon);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6153 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6154 else
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6155 return 0;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6156
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6157 /* Create the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6158 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
6159 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
6160
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
6161 /* 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
6162 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
6163 _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
6164
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6165 /* 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
6166 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
6167 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
6168 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
6169 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
6170 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
6171 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
6172
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6173 _create_tooltip(tmp, text);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6174 return tmp;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6175 }
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6176 #endif
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6177
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6184 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6186 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6187 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
6188 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
6189 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
6190 #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
6191 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
6192 {
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 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
6194 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
6195 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
6196 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
6197 }
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 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6199
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6200 tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6201 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6202 WS_CHILD | BS_PUSHBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6203 WS_VISIBLE | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6204 (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
6205 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6206 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
6207 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6208 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6209 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6210
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6211 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6212 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
6213
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6214 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
6215
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
6216 _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
6217
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6218 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6219 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6220 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
6221 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6222 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6223 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6224 SendMessage(tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6225 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6226 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6230 * 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
6231 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6232 * 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
6233 * 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
6234 * 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
6235 * DW pick the appropriate file extension.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6236 * (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
6237 */
507
c607eb385e58 Added missing calling conventions. Thanks Bastian for pointing this out.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 506
diff changeset
6238 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
6239 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6240 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6241 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6242 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
6243 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
6244 int windowtype = 0;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6245
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6246 if (!cinfo)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6247 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6248
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
6249 #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
6250 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
6251 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
6252 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
6253 {
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 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
6255 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
6256 }
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
6257 #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
6258 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
6259 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6260
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6261 #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
6262 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
6263 {
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 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
6265 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
6266 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
6267 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
6268 }
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 #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
6270 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6271 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
6272 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
6273 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
6274 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
6275 (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
6276 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6277 NULL);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6278
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6279 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6280 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
6281
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6282 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6283
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
6284 _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
6285
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
6286 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
6287 {
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 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
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 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
6291 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6292 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6293 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6294 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
6295 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6296
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 * 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
6299 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6300 * 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
6301 * 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
6302 * 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
6303 * (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
6304 * 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
6305 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6306 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
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 tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6309 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
6310 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
6311 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
6312 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
6313 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
6314 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
6315
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6316 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
6317 return 0;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6318
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6319 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
6320 if ( file != NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6321 {
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 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
6323 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
6324 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6325 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
6326 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
6327 #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
6328 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
6329 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
6330 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
6331 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
6332 #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
6333 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
6334 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
6335 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
6336 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6337 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
6338 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
6339 }
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
6340 #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
6341 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6342 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6343 {
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
6344 _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
6345 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
6346 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
6347 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6348 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6349 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6350 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6351
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6352 #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
6353 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
6354 {
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 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
6356 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
6357 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
6358 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
6359 }
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 #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
6361 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6362 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
6363 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
6364 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
6365 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
6366 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
6367 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
6368 (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
6369 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6370 NULL );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6371
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6372 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6373 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
6374
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6375 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
6376
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
6377 _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
6378
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
6379 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
6380 {
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 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
6382 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6383 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
6384 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6385 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6386 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6387 return tmp;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6388 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6389
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6390 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 * 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
6394 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6396 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6398 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
6399 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6400 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6401 WS_CHILD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6402 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
6403 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6404 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6405 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6406 DWInstance,
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 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6409 UPDOWN_CLASS,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6410 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6411 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6412 UDS_ARROWKEYS | UDS_SETBUDDYINT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6413 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
6414 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6415 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
6416 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6417 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6418 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6419 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6420
1025
3573878d1239 Make sure the initial spinbutton limits on Windows match the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1006
diff changeset
6421 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
6422 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6423 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6424 cinfo->buddy = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6425
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6426 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6427 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6428
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6429 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6430 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
6431 /* 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
6432 * 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
6433 * 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
6434 */
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6435 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
6436 {
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6437 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
6438 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6439
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6440 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6441 dw_window_set_font(buddy, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6442 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 * 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
6449 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6451 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6453 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6454 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6455 WS_CHILD | BS_AUTORADIOBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6456 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
6457 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6458 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
6459 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6460 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6461 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6462 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
6463 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6464 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
6465 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
6466 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
6467 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
6468 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
6469 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6470
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 * 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
6474 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6475 * 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
6476 * 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
6477 * 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
6478 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6479 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
6480 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6481 HWND tmp = CreateWindow(TRACKBAR_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6482 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6483 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6484 (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
6485 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6486 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
6487 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6488 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6489 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6490 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6491
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6492 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6495 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
6496 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
6497 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6501 * 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
6502 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6503 * 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
6504 * 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
6505 * 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
6506 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
6507 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
6508 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6509 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6510 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6511 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6512 (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
6513 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6514 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
6515 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6516 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6517 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6518 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6520 cinfo->back = cinfo->fore = -1;
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->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6523 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6524 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
6525 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
6526 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6527
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6528 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
6529 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530 * 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
6531 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6533 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6535 return CreateWindow(PROGRESS_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6536 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6537 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
6538 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6539 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
6540 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6541 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6542 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6544
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 * 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
6549 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6551 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6553 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
6554 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6555 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6556 WS_CHILD | BS_AUTOCHECKBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6557 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
6558 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6559 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
6560 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6561 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6562 NULL);
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6563 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
6564 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
6565 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
6566 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
6567 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
6568 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 * 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
6574 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6577 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6579 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6580 LISTBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6581 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6582 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6583 WS_CHILD | LBS_HASSTRINGS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6584 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6585 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
6586 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6587 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
6588 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6589 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6590 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6591 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6592
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6593 if(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6596 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6597 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6598
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6599 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
6600 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
6601 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6602
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6603 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6604 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6605 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6608 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 */
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
6614 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
6615 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6616 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
6617 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
6618
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6619 SendMessage(handle, WM_SETICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6620 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6621 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6622 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6623
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
6624 /* 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
6625 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
6626 {
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 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
6628 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
6629 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
6630
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6631 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
6632 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
6633
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 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
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 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
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 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
6639 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
6640 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
6641 (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
6642 (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
6643 }
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 #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
6645 /* 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
6646 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
6647 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6648 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
6649 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
6650 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
6651
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6652 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
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 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
6655 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
6656 _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
6657 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
6658 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
6659 }
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 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
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 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
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 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
6665 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
6666 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
6667 _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
6668 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
6669 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
6670 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
6671 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
6672 }
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
6673 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
6674 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6675 #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
6676 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
6677 {
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 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
6679 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
6680 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
6681 (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
6682 (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
6683 }
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
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 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
6686 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
6687 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
6688 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
6689
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 /* 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
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 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
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 /* 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
6695 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
6696 {
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 _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
6698 /* 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
6699 _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
6700 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6701 }
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6704 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6705 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 * 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
6708 * 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
6709 * (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
6710 * 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
6711 * 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
6712 * 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
6713 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6714 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
6715 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6716 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
6717 HANDLE icon = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6718
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6719 if(id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6720 {
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
6721 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
6722 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
6723 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6724 else if(filename)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6725 {
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
6726 #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
6727 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
6728 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6729 _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
6730 #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
6731 }
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
6732
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 _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
6734 }
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6735
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6736 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6737 * 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
6738 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6739 * 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
6740 * 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
6741 * (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
6742 * 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
6743 * 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
6744 * 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
6745 * 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
6746 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6747 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
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 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
6750 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
6751 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
6752 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
6753
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6754 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
6755 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6756 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
6757 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
6758 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6759 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
6760 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
6761 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6762 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
6763 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
6764 #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
6765 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
6766 #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
6767 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
6768 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
6769 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
6770 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
6771 #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
6772 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6773 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6774 {
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
6775 _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
6776 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
6777 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6778 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
6779 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6780 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6781 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6782 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
6783 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6784 }
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6785 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
6786 {
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6787 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
6788 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
6789 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6790
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
6791 _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
6792 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6793
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6795 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6797 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6798 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6801 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6803 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
6804 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
6805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6806 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6807
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6808 SetWindowText(handle, wtext);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6810 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6811 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
6812 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
6813 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
6814 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6815 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
6816 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
6817 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
6818 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6819 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
6820 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6821 /* groupbox */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6822 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6823 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
6824 SetWindowText( thisbox->grouphwnd, wtext );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6825 }
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
6826 /* 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
6827 {
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 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
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 /* 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
6831 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
6832 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6833 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
6834
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6835 _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
6836
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6837 /* 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
6838 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
6839 (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
6840 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6841 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
6842 item->width = newwidth;
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6843 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
6844 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
6845 /* 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
6846 _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
6847 }
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
6848 }
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
6849 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6850 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6851
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6852 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6853 * 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
6854 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6855 * 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
6856 * 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
6857 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6858 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
6859 {
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
6860 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
6861
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 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
6863 _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
6864 _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
6865 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6866
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6867 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6868 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6869 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6870 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6874 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6876 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
6877 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
6878 int len;
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6879
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6880 GetClassName(handle, tmpbuf, 99);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6881
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6882 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
6883 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6884 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
6885
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6886 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
6887 handle = cinfo->buddy;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6888 else
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6889 return NULL;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6890 }
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6891
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6892 /* 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
6893 * and fill it with the current text.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6894 */
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
6895 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
6896 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
6897 GetWindowText(handle, tempbuf, len);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6898
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6899 /* 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
6900 * 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
6901 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6902 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
6903 retbuf = _strdup(retbuf);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6904 return retbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6907 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6908 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6912 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 {
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
6914 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
6915 {
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
6916 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
6917 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
6918 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
6919
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6920 _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
6921 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
6922
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 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
6924 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
6925 }
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 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
6927 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6935 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 {
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
6937 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
6938 {
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
6939 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
6940 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
6941 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
6942
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
6943 _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
6944 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
6945
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 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
6947 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
6948 }
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 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6950 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6953 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6954
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6955 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
6956 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6957 if(GetWindowLong(handle, GWL_ID) == lParam)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6958 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6959 _dw_wfid_hwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6960 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6961 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6962 return TRUE;
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6963 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6964
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6971 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6973 _dw_wfid_hwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6974 EnumChildWindows(handle, _wfid, (LPARAM)id);
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6975 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
6976 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
6977
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6978 /* 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
6979 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
6980 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6981 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
6982 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
6983
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6984 /*
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6985 * 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
6986 * 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
6987 */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6988 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
6989 {
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6990 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
6991 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
6992 }
34f1d6f5f1c3 Added function dw_box_pack_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
34f1d6f5f1c3 Added function dw_box_pack_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 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
6995
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
6996 /* 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
6997 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
6998 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6999 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
7000 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
7001 {
34f1d6f5f1c3 Added function dw_box_pack_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 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
7003 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
7004 }
34f1d6f5f1c3 Added function dw_box_pack_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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7006 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
7007 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA);
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7008 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
7009 {
34f1d6f5f1c3 Added function dw_box_pack_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 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
7011 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
7012
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
7013 /* 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
7014 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
7015 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
7016 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
7017 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
7018 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
7019 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
7020
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7021 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
7022
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7023 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
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 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
7026 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
7027 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
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 }
34f1d6f5f1c3 Added function dw_box_pack_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
34f1d6f5f1c3 Added function dw_box_pack_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 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
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 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
7034 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
7035 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
7036 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
7037
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7038 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
7039 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
7040 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
7041 {
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
7042 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
7043 {
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
7044 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
7045 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
7046 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
7047 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
7048 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
7049 }
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 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
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 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
7053 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
7054 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
7055 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
7056
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 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
7058 }
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
7059 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7060
34f1d6f5f1c3 Added function dw_box_pack_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 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
7062 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
7063 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
7064 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
7065 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
7066 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
7067
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 /* 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
7069 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
7070 _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
7071
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7072 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
7073
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7074 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
7075 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
7076
34f1d6f5f1c3 Added function dw_box_pack_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 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
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 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
7080 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
7081 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7082 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
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 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
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 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
7087 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
7088 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
7089 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7090 }
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7091 #ifdef TOOLBAR
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7092 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
7093 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7094 #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
7095 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
7096 #endif
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7097 {
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7098 /* 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
7099 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
7100 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7101 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7102 #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
7103 /* 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
7104 _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
7105 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7106 }
34f1d6f5f1c3 Added function dw_box_pack_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 /*
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7109 * 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
7110 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7111 * 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
7112 * Returns:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7113 * 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
7114 */
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
7115 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
7116 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7117 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
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 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
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 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
7122
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7123 /* If 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
7124 * 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
7125 */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7126 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
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 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
7129 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
7130
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7131 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
7132 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
7133
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7134 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
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 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
7137 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
7138 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7139
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7140 if(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
7141 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
7142
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7143 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
7144 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7145 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
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 /* 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
7148 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
7149 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7150 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
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 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
7153 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7154 tmpitem[z-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
7155 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7156 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7157
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7158 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
7159 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
7160 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
7161 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
7162 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
7163 else
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 = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7165
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7166 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
7167 /* 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
7168 _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
7169 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
7170 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7171 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7172 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
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
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 * 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
7177 * Parameters:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7178 * 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
7179 * 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
7180 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7181 * 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
7182 */
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
7183 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
7184 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7185 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
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 /* 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
7188 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
7189 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7190 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
7191 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
7192 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
7193
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7194 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
7195 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7196 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
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 /* 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
7199 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
7200 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7201 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
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 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
7204 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7205 tmpitem[z-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
7206 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7207 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7208
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7209 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
7210 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
7211 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
7212 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
7213 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
7214 else
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 = 0;
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7216
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7217 /* 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
7218 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
7219 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
7220 /* 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
7221 _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
7222 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
7223 }
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 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
7225 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7226
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7227 /*
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7228 * 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
7229 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7230 * 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
7231 * 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
7232 * 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
7233 * 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
7234 * 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
7235 * 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
7236 * 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
7237 * 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
7238 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7239 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
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 _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
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
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7244 /*
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
7245 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 * 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
7248 * item: Window handle of the item to pack.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7255 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
7256 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7257 /* 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
7258 * 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
7259 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7260 _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
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
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 * 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
7265 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7266 * 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
7267 * 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
7268 * 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
7269 * 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
7270 * 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
7271 * 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
7272 * 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
7273 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7274 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
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 _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
7277 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 /*
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7280 * 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
7281 * 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
7282 */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7283 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
7284 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7285 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
7286
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7287 if(thisbox)
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 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
7290 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
7291 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
7292 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
7293 RECT rc = { 0 } ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7294
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7295 /* Calculate space requirements */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7296 _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
7297
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7298 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
7299 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
7300
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7301 /* 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
7302 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
7303
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7304 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
7305 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
7306 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7307 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7308
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7309 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7310 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7311 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7312 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7313 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7316 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7318 /* 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
7319 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
7320 _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
7321
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
7322 /* 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
7323 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 /*
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
7327 * 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
7328 * 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
7329 * 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
7330 * 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
7331 * 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
7332 */
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 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
7334 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7335 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
7336
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
7337 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
7338
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7339 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
7340 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7341 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
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 /* 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
7344 _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
7345
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 /* 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
7347 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
7348 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
7349 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7350 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
7351 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7352 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
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 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
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 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
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 /* 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
7359 _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
7360
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 /* 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
7362 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
7363 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
7364 }
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7365 }
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 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
7367 _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
7368 }
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
7369
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7371 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7373 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7375 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7381 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7383 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 /* 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
7387 unsigned long API dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7389 int bpp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7390 HDC hdc = GetDC(HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7391
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7392 bpp = GetDeviceCaps(hdc, BITSPIXEL);
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 ReleaseDC(HWND_DESKTOP, hdc);
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 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7397 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7398
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7399 /*
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7400 * 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
7401 * 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
7402 * Parameters:
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7403 * 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
7404 * 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
7405 * 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
7406 */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7407 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
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 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
7410 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
7411 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7412
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7413 /* 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
7414 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
7415 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7416 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
7417 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
7418
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7419 /* 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
7420 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
7421 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7422 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
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 /* 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
7425 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
7426 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
7427 /* 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
7428 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
7429 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
7430 /* 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
7431 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
7432 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
7433 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
7434 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
7435
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7436 /* 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
7437 *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
7438 *y = newy;
1493
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7439
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7440 /* Adjust the values to avoid Taskbar if requested */
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7441 if((horz | vert) & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7442 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7443 POINT pt = { 0, 0 };
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7444 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7445 MONITORINFO mi;
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7446
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7447 mi.cbSize = sizeof(MONITORINFO);
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 GetMonitorInfo(mon, &mi);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7450
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7451 if(horz & DW_GRAV_OBSTACLES)
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 & 0xf) == DW_GRAV_LEFT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7454 *x += (mi.rcWork.left - mi.rcMonitor.left);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7455 else if((horz & 0xf) == DW_GRAV_RIGHT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7456 *x -= (mi.rcMonitor.right - mi.rcWork.right);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7457 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7458 if(vert & DW_GRAV_OBSTACLES)
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 & 0xf) == DW_GRAV_TOP)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7461 *y += (mi.rcWork.top - mi.rcMonitor.top);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7462 else if((vert & 0xf) == DW_GRAV_BOTTOM)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7463 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7464 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7465 }
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7466 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7467 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7469 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7476 void API dw_window_set_pos(HWND handle, long x, long y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7478 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
7479 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
7480
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 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
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 /* 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
7484 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
7485 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
7486
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7487 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
7488 _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
7489 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7492 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7501 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
7502 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7503 /* 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
7504 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
7505 _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
7506
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7507 _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
7508 /* 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
7509 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7511
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7521 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
7522 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7523 WINDOWPLACEMENT wp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7524
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7525 wp.length = sizeof(WINDOWPLACEMENT);
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 GetWindowPlacement(handle, &wp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7528 if( wp.showCmd == SW_SHOWMAXIMIZED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7529 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7530 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7531 *x=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7532 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7533 *y=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7534 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7535 *width=dw_screen_width();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7536 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7537 *height=dw_screen_height();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7538 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7539 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7540 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7541 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7542 *x = wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7543 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7544 *y = wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7545 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7546 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7547 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7548 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7549 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7550 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7552 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7553 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7559 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 {
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
7561 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
7562 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
7563 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
7564
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7565 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
7566 return;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7567
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
7568 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
7569 {
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 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
7571 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
7572 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
7573
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7574 _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
7575 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
7576
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 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
7578 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
7579 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
7580 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7581
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7582 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
7583
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
7584 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
7585 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7586
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7587 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7588 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7589 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
7590 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7591 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
7592
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7593 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
7594 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7595 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
7596
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
7597 /* 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
7598 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
7599 _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
7600
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7601 return;
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7602 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7603 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7604 #endif
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7605
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7606 tmp = currentstyle | mask;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7607 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
7608 tmp |= style & mask;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7609
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
7610 /* 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
7611 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
7612 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
7613 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
7614 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7615 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
7616 #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
7617 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
7618 {
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
7619 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
7620
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7621 if(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
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 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
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 /* 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
7626 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
7627 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
7628 _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
7629 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7630 else
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 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
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 /* 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
7635 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
7636 _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
7637 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7638 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7639 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7640 }
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7641 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
7642 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7643 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
7644 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
7645 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
7646
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7647 /* 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
7648 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
7649 tmp ^= thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7650 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
7651
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7652 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
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(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
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(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7657 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
7658 else
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7659 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7660 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
7661 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
7662 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
7663
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7664 cinfo->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
7665 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
7666 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7667 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7668 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
7669 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
7670 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7671 /* 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
7672 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
7673 tmp &= ~(0xFL);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7674 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
7675 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
7676 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
7677 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
7678 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
7679 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
7680 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7681
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7682 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
7683 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7684
5c66a108aa47 Fixed 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 /* 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
7686 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
7687 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7688 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7689
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7690 for(z=0;z<256;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 if(array[z] && array[z]->realid == pageid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7693 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7694 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7695 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7696 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7699 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7705 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7707 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
7708
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7709 if(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 int z, refid = -1;
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 for(z=0;z<256;z++)
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 if(_findnotebookid(array, z) == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7716 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7717 refid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7718 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7719 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7720 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7721
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7722 if(refid == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7723 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7724
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7725 for(z=0;z<256;z++)
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 if(!array[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 array[z] = calloc(1, sizeof(NotebookPage));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7730 array[z]->realid = refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7731 array[z]->item.mask = TCIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7732 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
7733 array[z]->item.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7734 TabCtrl_InsertItem(handle, z, &(array[z]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7735 return refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7736 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7737 }
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 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7740 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7741
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7742 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7743 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7744 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7746 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7749 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
7750 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7751
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7752 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
7753 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7754
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7755 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7756 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7757
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7758 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && array[pageid])
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 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
7763 array[pageid]->item.pszText = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7764 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7765 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7766 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7767 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7768
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7769 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7770 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7771 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7772 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7773 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7776 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 }
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 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7782 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7783 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7786 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7787 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
7788 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7789 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
7790 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7791
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7792 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7793 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7794
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7795 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && array[pageid])
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 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
7800
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7801 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
7802 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7803 dw_window_destroy(array[pageid]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7804 array[pageid]->hwnd = tmpbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7805 if(pageidx == dw_notebook_page_get(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7806 {
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
7807 ShowWindow(tmpbox, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7808 SetParent(tmpbox, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7809 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7810 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7811 }
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
7812 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7813
5c66a108aa47 Fixed 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 * 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
7816 * 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
7817 * 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
7818 * 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
7819 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7820 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
7821 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7822 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
7823 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
7824 HWND pagehwnd = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7825
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7826 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7827 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7828
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7829 pageid = _findnotebookid(array, pageidx);
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 if(pageid < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7832 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7833
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7834 if(array[pageid])
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 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
7837 pagehwnd = array[pageid]->hwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7838 free(array[pageid]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7839 array[pageid] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7840 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7842 TabCtrl_DeleteItem(handle, pageid);
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 /* Shift the pages over 1 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7845 for(z=pageid;z<255;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7846 array[z] = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7847 array[255] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7848
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7849 for(z=0;z<256;z++)
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 if(array[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 newid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7854 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7855 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7856 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7857 if(newid > -1)
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 SetParent(array[newid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7860 _resize_notebook_page(handle, newid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7861 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
7862 }
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
7863 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
7864 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
7865 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7866
5c66a108aa47 Fixed 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 * 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
7869 * 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
7870 * 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
7871 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7872 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
7873 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7874 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
7875 int physid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7876
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7877 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
7878 return array[physid]->realid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7879 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
7880 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7881
5c66a108aa47 Fixed 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 * 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
7884 * 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
7885 * 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
7886 * 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
7887 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7888 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
7889 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7890 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
7891 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7892
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7893 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7894 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7895
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7896 pageid = _findnotebookid(array, pageidx);
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 if(pageid > -1 && pageid < 256)
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 int oldpage = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7901
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7902 if(oldpage > -1 && array && array[oldpage])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7903 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7904
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7905 TabCtrl_SetCurSel(handle, pageid);
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 SetParent(array[pageid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7908 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7909 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7918 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7920 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7921
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7922 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7923
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7924 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
7925 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7926 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
7927 0, (LPARAM)UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7928 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7929 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7930 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
7931 0, (LPARAM)UTF8toWide(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7932 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7933
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7935 * 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
7936 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7937 * 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
7938 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7939 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7940 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7941 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
7942 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7943 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7944 int listbox_type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7945 int i;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7947 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7948
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7949 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
7950 listbox_type = CB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7951 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7952 listbox_type = LB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7954 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
7955 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
7956 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7957
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7958 /*
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7959 * 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
7960 * Parameters:
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7961 * handle: Handle to the listbox to be appended to.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7962 * text: Text to append into listbox.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7963 * pos: 0 based position to insert text
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7964 */
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7965 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
7966 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7967 TCHAR tmpbuf[100] = {0};
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7968
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7969 GetClassName(handle, tmpbuf, 99);
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7970
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7971 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7972 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7973 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
7974 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7975 else
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7976 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7977 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
7978 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7979 }
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7980
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7981 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7982 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7984 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7986 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7988 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7989
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7990 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7991
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7992 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
7993 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7994 char *buf = dw_window_get_text(handle);
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 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7997 CB_RESETCONTENT, 0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7998
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7999 if(buf)
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 dw_window_set_text(handle, buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8002 free(buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8003 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8004 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8005 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8006 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8007 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
8008 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8009
5c66a108aa47 Fixed 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 * 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
8012 * 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
8013 * 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
8014 * 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
8015 * 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
8016 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8017 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
8018 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8019 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8020
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8021 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8022
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8023 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
8024 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8025 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8026 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
8027 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8028 else
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 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
8031 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8032 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
8033 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8034 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
8035 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8038 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8039 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8040 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8041 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8046 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
8047 {
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8048 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
8049 unsigned int len;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8050
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
8051 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
8052
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 if(!buffer || !length)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8054 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8055
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8056 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8057
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8058 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
8059 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8060 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
8061
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
8062 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
8063 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8064 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
8065 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
8066 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8067 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8068 else
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 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
8071
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
8072 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
8073 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8074 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
8075 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
8076 }
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8077 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8078 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 */
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
8085 int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8087 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8088
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8089 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8090
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8091 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
8092 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8093 CB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8094 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8095
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8096 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8097 LB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8098 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8099 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8104 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8105 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8107 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8109 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
8110 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8111
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8112 GetClassName(handle, tmpbuf, 99);
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 /* 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
8115 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
8116 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8117
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8118 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
8119 if(count > 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8120 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8121 array = malloc(sizeof(int)*count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8122 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
8123
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8124 if(where == -1)
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 int ret = array[0];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8127 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8128 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8129 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8130 for(z=0;z<count;z++)
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 if(array[z] == where && (z+1) < count)
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 int ret = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8135 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8136 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8137 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8138 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8139 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8140 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8141 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8145 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8151 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8153 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8154
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8155 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8156
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8157 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
8158 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8159 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8160 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8161 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8162 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
8163 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8164 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8165 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8168 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8173 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8175 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8176
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8177 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8178
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8179 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
8180 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8181 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8182 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
8183 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8184
5c66a108aa47 Fixed 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 * 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
8187 * 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
8188 * 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
8189 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8190 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
8191 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8192 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8193
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8194 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8195
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8196 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
8197 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8198 CB_GETCOUNT,0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8199
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8200 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8201 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
8202 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8203
5c66a108aa47 Fixed 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 * 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
8206 * 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
8207 * 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
8208 * 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
8209 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8210 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
8211 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8212 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8213
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8214 GetClassName(handle, tmpbuf, 99);
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 /* 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
8217 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
8218 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8219
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8220 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
8221 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8222
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8223 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8224 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8225 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8230 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8232 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
8233 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8234
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8235 if(startpoint < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8236 startpoint = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8237
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8238 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
8239 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
8240
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8241 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
8242
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8243 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8244 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8245 TCHAR *dest, *start;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8246 int copylen = len - startpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8247
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8248 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8249
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
8250 dest = &tmpbuf[startpoint+textlen];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8251 start = &tmpbuf[startpoint];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8252
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8253 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
8254 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
8255 }
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8256 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
8257
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8258 SetWindowText(handle, tmpbuf);
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 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
8261 return (startpoint + textlen);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8262 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8263
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8264 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8265 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267 * 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
8268 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8270 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8272 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8274 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
8275 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
8276
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8277 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8278 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8279
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8280 buffer[0] = 0;
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 if(startpoint < len)
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 max = MIN(length, len - startpoint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8285
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8286 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8287 buffer[max] = '\0';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8288 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8289
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8290 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8293 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8294 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8300 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8302 if(bytes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8303 *bytes = GetWindowTextLength(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8304 if(lines)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8305 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8306 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8308 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8309 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8311 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8315 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8317 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
8318 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
8319
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8320 GetWindowText(handle, tmpbuf, len+1);
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 if(startpoint + length < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8323 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8324 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8325
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8326 SetWindowText(handle, tmpbuf);
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8329 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8332 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8333 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8334 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8337 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8339 SetWindowText(handle, TEXT(""));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8343 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8344 * 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
8345 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8348 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8350 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
8351 dw_mle_set_cursor(handle, point);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8352 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8355 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8356 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8357 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8358 * 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
8359 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8360 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
8361 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8362 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
8363 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8364
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 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8367 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8368 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8369 * 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
8370 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8371 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
8372 {
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
8373 /* 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
8374 * horizontal scrollbar it word wraps.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8375 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8376 if(state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8377 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
8378 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8379 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
8380 /* 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
8381 if(hrichedit)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8382 {
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8383 if(state)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8384 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
8385 else
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_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
8387 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8388 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8389
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8390 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8392 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8393 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8396 void API dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 {
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8398 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
8399 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8410 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8412 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
8413 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
8414 TCHAR *searchtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8415 int z, textlen, retval = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8416
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8417 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8418
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
8419 textlen = (int)strlen(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8420
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8421 if(flags & DW_MLE_CASESENSITIVE)
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 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
8424 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8425 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
8426 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8427 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8428 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8429 else
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 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
8432 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8433 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
8434 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8435 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8436 }
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 if(retval)
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 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
8441 SendMessage(handle, EM_SCROLLCARET, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8442 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8443
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8444 free(tmpbuf);
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 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8447 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8448
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8453 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8454 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 }
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 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8460 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8463 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
8468 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469 * 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
8470 * 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
8471 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8472 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8473 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 {
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
8475 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
8476 {
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 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
8478 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
8479 {
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 /* 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
8481 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
8482 /* 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
8483 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
8484 }
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 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
8486 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
8487 }
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 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
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 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
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 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
8493
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8494 if(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
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 /* 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
8497 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
8498 /* 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
8499 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
8500 }
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 }
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 /* 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
8503 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
8504 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8505 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8507 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8508 * 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
8509 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8510 * 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
8511 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8512 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
8513 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8514 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
8515 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8516
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8517 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8518 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
8519 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
8520 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8521
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 * 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
8524 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8525 * 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
8526 * 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
8527 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8528 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
8529 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8530 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
8531 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8532
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8533 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8534 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
8535 else
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)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
8537 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8538
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8539 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8540 * 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
8541 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8542 * 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
8543 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8544 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
8545 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8546 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
8547 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8548
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 * 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
8551 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8552 * 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
8553 * 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
8554 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8555 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
8556 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
8557 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
8558 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
8559 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8560
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 * 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
8563 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8564 * 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
8565 * 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
8566 * 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
8567 */
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 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
8569 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8570 SCROLLINFO si;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8571
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8572 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8573 si.fMask = SIF_RANGE | SIF_PAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8574 si.nMin = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8575 si.nMax = range - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8576 si.nPage = visible;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8577 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
8578 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8579
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8580 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8581 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8586 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8588 TCHAR tmpbuf[101] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8589 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8590
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8591 _sntprintf(tmpbuf, 100, TEXT("%ld"), position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8592
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8593 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8594 SetWindowText(cinfo->buddy, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8595
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
8596 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8597 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8598
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 * 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
8603 * 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
8604 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8606 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607 {
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
8608 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8610
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8617 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8619 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
8620 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8627 long API dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 {
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
8629 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8637 int API dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8639 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
8640 return (in_checkbox_handler ? FALSE : TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8641 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8643
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8644 /* 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
8645 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
8646 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8647 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8648
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8649 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8650
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8651 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
8652 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8653 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
8654 SendMessage(handle, BM_SETCHECK, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8655 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8656 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
8657 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8658 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8659 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8660 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8661 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8662 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8663 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8664 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8665 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8666 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
8667 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8668 HWND parent = GetParent(handle);
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 if(parent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8671 EnumChildWindows(parent, _uncheck_radios, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8672 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8673 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8674 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8675
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8677 * 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
8678 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8679 * 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
8680 * 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
8681 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8682 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8683 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8684 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8685 */
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
8686 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
8687 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8688 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8689 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8690 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8691 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8692
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8693 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8694 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8695
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8696 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
8697 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
8698 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
8699 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8700 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
8701
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8702 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8703 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8704 tvins.hInsertAfter = item ? item : TVI_FIRST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8705
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8706 hti = TreeView_InsertItem(handle, &tvins);
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 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8709 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8710
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8711 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8712 * 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
8713 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8714 * 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
8715 * 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
8716 * 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
8717 * 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
8718 * 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
8719 */
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
8720 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
8721 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8722 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8723 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8724 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8725 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8726
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8727 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8728 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8729
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8730 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
8731 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
8732 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
8733 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8734 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
8735
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8736 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8737 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8738 tvins.hInsertAfter = TVI_LAST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8739
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8740 hti = TreeView_InsertItem(handle, &tvins);
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 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
8743 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8744
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8745 /*
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
8746 * 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
8747 * 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
8748 * 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
8749 * 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
8750 * 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
8751 * 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
8752 */
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
8753 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
8754 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8755 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8756 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8757
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8758 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8759 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8760
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8761 if(TreeView_GetItem(handle, &tvi))
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8764 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8765 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8766
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8767 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
8768 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
8769 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8770 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
8771 tvi.hItem = (HTREEITEM)item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8772
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8773 TreeView_SetItem(handle, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8774 }
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
8775 }
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
8776
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 * 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
8779 * 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
8780 * 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
8781 * 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
8782 * 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
8783 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8784 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
8785 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8786 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8787 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8788
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8789 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8790 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8791
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8792 if(TreeView_GetItem(handle, &tvi))
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8795 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8796 }
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
8797 }
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
8798
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 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8800 * 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
8801 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8802 * 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
8803 * 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
8804 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8805 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
8806 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8807 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8808 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8809
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
8810 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8811 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8813 if(TreeView_GetItem(handle, &tvi))
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8816 return ptrs[1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8817 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8818 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
8819 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8820
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8821 /*
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8822 * 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
8823 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8824 * 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
8825 * 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
8826 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8827 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
8828 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8829 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8830
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8831 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8832 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8833
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8834 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
8835 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
8836 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
8837 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8838
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 * 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
8841 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8842 * 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
8843 * 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
8844 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8845 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
8846 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8847 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
8848 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8849
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8850 /*
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
8851 * 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
8852 * 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
8853 * 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
8854 * 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
8855 */
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
8856 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
8857 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8858 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
8859 }
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
8860
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8861 /* 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
8862 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
8863 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8864 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8865
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8866 hti = TreeView_GetChild(handle, node);
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 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8869 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8870 HTREEITEM lastitem = 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 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8873 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8874 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8875 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8876
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
8877 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8878 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8879 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8880 * 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
8881 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8882 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
8883 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8884 HTREEITEM hti = TreeView_GetRoot(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8885
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8886 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
8887 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8888 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8889 HTREEITEM lastitem = 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 _dw_tree_item_delete_recursive(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8892 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8893 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8894 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8895 dw_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
8896 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8897
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8898 /*
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
8899 * 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
8900 * 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
8901 * 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
8902 * 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
8903 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8904 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
8905 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8906 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
8907 }
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
8908
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 * 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
8911 * 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
8912 * 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
8913 * 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
8914 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8915 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
8916 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8917 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
8918 }
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
8919
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 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8921 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8922 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8923 * 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
8924 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8925 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8926 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
8927 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8928 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8929 void **ptrs=NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8930
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8931 if(item == TVI_ROOT || !item)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8932 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8934 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8935 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8936
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8937 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8938 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8939
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8940 _dw_tree_item_delete_recursive(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8941 TreeView_DeleteItem(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8942 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8943 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
8944 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8945
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8946 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8948 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 * 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
8954 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8955 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8956 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
8957 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8958 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8959 int z, l = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8960 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
8961 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8962
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8963 if(separator == -1)
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 tempflags[0] = DW_CFA_RESERVED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8966 l = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8967 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8968
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8969 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
8970 tempflags[count + l] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8971 cinfo->flags = tempflags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8972 cinfo->columns = count + l;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8973
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8974
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8975 for(z=0;z<count;z++)
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 if(titles[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 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
8980 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
8981 lvc.cchTextMax = (int)_tcslen(lvc.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8982 if(flags[z] & DW_CFA_RIGHT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8983 lvc.fmt = LVCFMT_RIGHT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8984 else if(flags[z] & DW_CFA_CENTER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8985 lvc.fmt = LVCFMT_CENTER;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8986 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8987 lvc.fmt = LVCFMT_LEFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8988 lvc.cx = 75;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8989 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8990 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
8991 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8992 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8993 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
8994 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8995 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8996
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8997 /*
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
8998 * 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
8999 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9000 * 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
9001 * 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
9002 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9003 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
9004 {
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
9005 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
9006
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9007 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
9008 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9009
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9010 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9011 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9012 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9013 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9014 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9015 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9017 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9018 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9019 {
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9020 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
9021 LV_COLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9022
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9023 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
9024 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
9025 lvc.cchTextMax = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9026 lvc.fmt = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9027 if(!count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9028 lvc.cx = 300;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9029 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9030 lvc.cx = 150;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9031 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9032 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
9033 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
9034 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9035 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9036 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
9037 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
9038 }
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
9039 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9042 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9043 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 */
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
9050 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
9051 {
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 return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9053 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9055 /*
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
9056 * 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
9057 * 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
9058 * 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
9059 * 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
9060 * (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
9061 */
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
9062 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
9063 {
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
9064 #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
9065 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
9066 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9067 char *file = malloc(strlen(filename) + 5);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9068 HANDLE icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9069
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9070 if(!file)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9071 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9072
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9073 strcpy(file, filename);
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 /* 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
9076 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9077 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9078 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9079 strcat(file, ".ico");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9080 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9081 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9082 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9083 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9084 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9085 }
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9086 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
9087 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
9088 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
9089 #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
9090 }
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
9091
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 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9093 * 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
9094 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9095 * 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
9096 * 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
9097 * (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
9098 */
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
9099 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
9100 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
9101 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
9102 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
9103 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
9104
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9105 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
9106 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
9107 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
9108 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
9109 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9110 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
9111 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
9112 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9113 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
9114 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
9115 #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
9116 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
9117 #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
9118 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
9119 #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
9120 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9121 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9122 {
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
9123 _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
9124 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
9125 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
9126 }
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
9127 _unlink( file );
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
9128 free( file );
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9129 }
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
9130 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
9131 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9132
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9133 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9134 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9135 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9136 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9137 */
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
9138 void API dw_icon_free(HICN handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9140 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9144 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9147 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9148 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9149 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9151 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9152 int z, item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9153
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9154 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
9155 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9156 /* Insert at the end */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9157 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
9158 lvi.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9159 lvi.cchTextMax = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9160 lvi.iImage = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9161
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9162 ShowWindow(handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9163 item = ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9164 for(z=1;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9165 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
9166 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
9167 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
9168 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9169
5c66a108aa47 Fixed 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 /* 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
9171 * 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
9172 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9173 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
9174 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9175 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9176 static HWND lasthwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9177
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
9178 /* 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
9179 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
9180 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
9181
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9182 if(!hSmall || !hLarge)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9183 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9184 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
9185 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
9186 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9187 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
9188 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9189 if(!lookup[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 lookup[z] = hicon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9192 ImageList_AddIcon(hSmall, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9193 ImageList_AddIcon(hLarge, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9194 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9195 {
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
9196 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9197 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9198 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9199 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9200 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
9201 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9202 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9203 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9204 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9205 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9206
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9207 if(hicon == lookup[z])
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(lasthwnd != handle)
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(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9212 {
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
9213 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9214 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9215 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9216 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9217 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
9218 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9219 }
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9220 lasthwnd = handle;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9221 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9222 return z;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9225 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
9226 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9227
5c66a108aa47 Fixed 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 * 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
9230 * 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
9231 * 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
9232 * 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
9233 * 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
9234 * 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
9235 * 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
9236 */
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
9237 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
9238 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9239 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
9240 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9241
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 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
9243 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9244 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
9245 }
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9246
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9247 lvi.iItem = row + item;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9248 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9249 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
9250 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
9251 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9252 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
9253
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9254 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
9255 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9256
5c66a108aa47 Fixed 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 * 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
9259 * 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
9260 * 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
9261 * 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
9262 * 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
9263 * 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
9264 * 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
9265 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9266 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
9267 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9268 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9270
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9271 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9272 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9274 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9276 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9277 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9278 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9279 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9280 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
9281 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9282 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9283 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9284 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
9285 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
9286 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9287
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 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
9289 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9290 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
9291 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9292
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9293 if(!cinfo || !cinfo->flags)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9294 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9295
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9296 flags = cinfo->flags;
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 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9299 lvi.iItem = row + item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9300 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
9301 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
9302 lvi.cchTextMax = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9303
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9304 if(flags[column] & DW_CFA_BITMAPORICON)
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 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9307 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
9308
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9309 if(data)
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 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
9312
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9313 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
9314 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9315 else
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9316 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
9317 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9318 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
9319 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9320 char *tmp = *((char **)data);
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 if(!tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9323 tmp = "";
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9324
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9325 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
9326 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
9327 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9328 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
9329 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9330 ULONG tmp = *((ULONG *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9331
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9332 _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
9333
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9334 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9335 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9336 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
9337 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9338 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9339 CDATE cdate = *((CDATE *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9340
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9341 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
9342
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9343 /* 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
9344 * Visual Studio 2008. -Brian
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9345 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9346 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
9347 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9348 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
9349 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
9350 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
9351 _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
9352 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9353
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9354 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9355 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9356 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
9357 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9358 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9359 CTIME ctime = *((CTIME *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9360
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9361 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
9362 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
9363 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
9364
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9365 _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
9366
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9367 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9368 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9369
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9370 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
9371 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9372
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9373 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9374 * 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
9375 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9376 * 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
9377 * 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
9378 * 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
9379 * 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
9380 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9381 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
9382 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9383 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
9384 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9385
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9386 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9387 * 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
9388 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9389 * 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
9390 * 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
9391 * 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
9392 * 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
9393 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9394 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
9395 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9396 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
9397 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9398
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 * 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
9401 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9402 * 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
9403 * 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
9404 * 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
9405 * 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
9406 * 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
9407 */
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
9408 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
9409 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9410 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
9411 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9412
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9413 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9414 * 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
9415 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9416 * 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
9417 * 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
9418 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9419 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
9420 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9421 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9422 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9423 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9424
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9425 if(!cinfo || !cinfo->flags)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9426 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9427
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9428 flags = cinfo->flags;
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 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9431 rc = DW_CFA_BITMAPORICON;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9432 else if(flags[column] & DW_CFA_STRING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9433 rc = DW_CFA_STRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9434 else if(flags[column] & DW_CFA_ULONG)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9435 rc = DW_CFA_ULONG;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9436 else if(flags[column] & DW_CFA_DATE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9437 rc = DW_CFA_DATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9438 else if(flags[column] & DW_CFA_TIME)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9439 rc = DW_CFA_TIME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9440 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9441 rc = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9442 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
9443 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9444
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 * 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
9447 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9448 * 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
9449 * 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
9450 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9451 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
9452 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9453 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
9454 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9455
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9456 /*
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9457 * 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
9458 * Parameters:
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9459 * 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
9460 * 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
9461 * 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
9462 * 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
9463 * 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
9464 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9465 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
9466 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9467 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
9468 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
9469 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
9470 temp = _internal_color(evencolor);
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9471 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
9472
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9473 /* Drop out on error */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9474 if(!cinfo)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9475 return;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9476
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9477 /* 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
9478 if(oddcolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9479 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
9480 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9481 cinfo->odd = oddcolor;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9482
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9483 if(evencolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9484 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
9485 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9486 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
9487 }
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9488
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9489 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9490 * 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
9491 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9492 * 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
9493 * 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
9494 * 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
9495 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9496 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
9497 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9498 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9499 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9500
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
9501 /* 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
9502 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
9503 {
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 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
9505 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9506
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
9507 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
9508 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9509 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
9510 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9511
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 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
9513 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
9514 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
9515 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
9516
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 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
9518 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
9519
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9520 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9521
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9522 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9523 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9524 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9525 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9526 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9527 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9528 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9529 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9530 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9531 _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
9532 }
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
9533
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 * 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
9536 * 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
9537 * 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
9538 * 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
9539 * 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
9540 */
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 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
9542 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9543 _dw_container_set_row_title(handle, NULL, row, title);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9549 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9553 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9555 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9557
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561 * 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
9562 * 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
9563 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9564 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9566 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9568
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9570 * 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
9571 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9572 * 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
9573 * 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
9574 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9575 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
9576 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9577 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
9578
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9579 for(z=0;z<rowcount;z++)
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 ListView_DeleteItem(handle, 0);
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 if(rowcount > _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9584 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
9585 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9586 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
9587 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9588
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 * 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
9591 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9592 * 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
9593 * 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
9594 * 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
9595 * 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
9596 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9597 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
9598 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9599 switch(direction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9600 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9601 case DW_SCROLL_TOP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9602 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
9603 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9604 case DW_SCROLL_BOTTOM:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9605 ListView_Scroll(handle, 0, 10000000);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9606 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9607 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9608 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9609
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9610 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9612 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9617 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9618 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9619 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9620 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9621 int _index = ListView_GetNextItem(handle, -1, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9622
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9623 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9624 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9625
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9626 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9629 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9630
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9631 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9632
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9633 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
9634 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9635 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9636
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9645 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9647 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
9648 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
9649
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9650 _index = ListView_GetNextItem(handle, _index, flags);
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 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9653 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9654
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9655 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9658 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9659
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9660 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9661
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9662 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
9663 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9667 * 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
9668 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9669 * 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
9670 * 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
9671 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9672 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
9673 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9674 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
9675 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
9676
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9677 while ( index != -1 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9678 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9679 LV_ITEM lvi;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9684 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9685
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9686 ListView_GetItem( handle, &lvi );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9687
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
9688 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
9689 {
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
9690 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
9691
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9692 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
9693 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
9694 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
9695 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
9696 ListView_EnsureVisible( handle, index, TRUE );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9697 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9698 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9699
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9700 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
9701 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9702 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9703
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9704 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9705 * 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
9706 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9707 * 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
9708 * 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
9709 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9710 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
9711 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9712 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
9713 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
9714
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9715 while(index != -1)
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 LV_ITEM lvi;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9722 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9723
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9724 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9725
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
9726 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
9727 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9728 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
9729
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9730 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
9731 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
9732
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9733 ListView_DeleteItem(handle, index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9734 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9735 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9736
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9737 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
9738 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9739 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9740
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9741 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9742 * 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
9743 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9744 * 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
9745 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9746 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
9747 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9748 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9749 if(cinfo && cinfo->columns == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9750 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9751 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
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 else if(cinfo && cinfo->columns > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9754 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9755 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
9756 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
9757 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
9758 int index;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9759
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9760 /* Initialize with sizes of column labels */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9761 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9762 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9763 if(flags[z] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9764 columns[z] = 5;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9765 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9766 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9767 LVCOLUMN lvc;
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 lvc.mask = LVCF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9770 lvc.cchTextMax = 1023;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9771 lvc.pszText = text;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9772
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9773 if(ListView_GetColumn(handle, z, &lvc))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9774 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9775
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9776 if(flags[z] & DW_CFA_RESERVED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9777 columns[z] += 20;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9779 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9780
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9781 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
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 /* Query all the item texts */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9784 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9785 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9786 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9787 {
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
9788 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
9789
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9790 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
9791 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
9792
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9793 /* 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
9794 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
9795 width += 20;
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9796
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9797 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
9798 columns[z] = width;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9799 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9800
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9801 index = ListView_GetNextItem(handle, index, LVNI_ALL);
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
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9804 /* 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
9805 * 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
9806 * 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
9807 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9808 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9809 ListView_SetColumnWidth(handle, z, columns[z] + 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9810
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9811 free(columns);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9812 free(text);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9813 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9814 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9815
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9816 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9817 * 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
9818 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9819 * 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
9820 * 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
9821 * 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
9822 */
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
9823 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
9824 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9825 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9826
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9827 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9828 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
9829 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9830 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
9831 tnid.uCallbackMessage = WM_USER+2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9832 tnid.hIcon = (HICON)icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9833 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
9834 _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
9835 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9836 tnid.szTip[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9837
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9838 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
9839 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9840
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 * 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
9843 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9844 * 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
9845 * 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
9846 */
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
9847 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
9848 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9849 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9851 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9852 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
9853 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9854
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9855 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
9856 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9857
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9858 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9859 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9860 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9862 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9863 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9865 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9867 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9868 HWND tmp = CreateWindow(ObjectClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
9869 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9870 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
9871 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9872 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
9873 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9874 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9875 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9876 newbox->pad = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9877 newbox->type = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9878 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9879 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9880 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9881 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
9882 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
9883 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9884 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9886 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9892 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9894 HPEN hPen = TlsGetValue(_hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9895 HBRUSH hBrush = TlsGetValue(_hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9896 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
9897 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9898 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
9899 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
9900 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
9901 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9902
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9903 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9904 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
9905 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9906 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
9907
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9908 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
9909 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
9910 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
9911 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
9912 #endif
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
9913
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9914 DeleteObject(hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9915 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
9916 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
9917 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
9918 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9927 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9929 COLORREF background;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9930
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9931 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9932 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
9933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9934 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
9935 TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9936 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9937 TlsSetValue(_background, (LPVOID)(uintptr_t)background);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9938 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9939
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9940 /* 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
9941 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9942 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9943 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9944 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9945 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9946 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9947 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9948 CHOOSECOLOR cc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9949 unsigned long newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9950 COLORREF acrCustClr[16] = {0};
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9951
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9952 value = _internal_color(value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9953 if(value == DW_RGB_TRANSPARENT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9954 newcolor = DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9955 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9956 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
9957 ZeroMemory(&cc, sizeof(CHOOSECOLOR));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9958 cc.lStructSize = sizeof(CHOOSECOLOR);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9959 cc.rgbResult = newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9960 cc.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9961 cc.lpCustColors = (LPDWORD)acrCustClr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9962 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9963 if (ChooseColor(&cc) == TRUE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9964 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
9965 return newcolor;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9966 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9967
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9968 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9969 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9971 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9975 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9977 #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
9978 /* 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
9979 * 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
9980 */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9981 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
9982 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9983 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9984
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9985 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9986 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9987 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9988 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9989 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9990 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9991
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9992 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
9993 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9994 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
9995 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9996 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10007 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
10008 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10009 #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
10010 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
10011 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
10012
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10013 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
10014 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
10015 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
10016 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
10017 else
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10018 return;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10019
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10020 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
10021 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
10022 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
10023 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10024 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10025 HPEN oldPen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10026
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10027 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10028 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10029 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10030 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10031 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10032 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10033
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10034 oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10035 MoveToEx(hdcPaint, x1, y1, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10036 LineTo(hdcPaint, x2, y2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10037 SelectObject(hdcPaint, oldPen);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10038 /* For some reason Win98 (at least) fails
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10039 * 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
10040 */
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10041 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
10042 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10043 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
10044 #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
10045 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10046
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10047 /* 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
10048 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
10049 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10050 POINT *points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10051 int i;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10052
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10053 /*
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10054 * 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
10055 * 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
10056 * 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
10057 */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10058 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
10059
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10060 if(points)
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 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
10063 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10064 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
10065 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
10066 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10067 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
10068 && 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
10069 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10070 /* 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
10071 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
10072 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
10073 /* ... 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
10074 (*npoints)++;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10075 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10076 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10077 return points;
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
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10080 /* 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
10081 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10082 * handle: Handle to the window.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10083 * 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
10084 * 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
10085 * number of points
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10086 * x[]: X coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10087 * y[]: Y coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10088 */
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
10089 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
10090 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
10091 POINT *points = NULL;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10092
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10093 /* Sanity check */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10094 if(npoints < 1)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10095 return;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10096
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10097 #ifdef GDIPLUS
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 GpGraphics *graphics = NULL;
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 if(handle)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10102 GdipCreateFromHWND(handle, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10103 else if(pixmap)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10104 GdipCreateFromHDC(pixmap->hdc, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10105 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10106 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10107
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10108 /* 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
10109 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
10110 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
10111
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10112 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
10113 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10114 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
10115 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10116 GpBrush *brush = TlsGetValue(_gpBrush);
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 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
10119 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10120 else
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 GpPen *pen = TlsGetValue(_gpPen);
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 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
10125 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10126 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10127 GdipDeleteGraphics(graphics);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10128 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10129 #else
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10130 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10131 HDC hdcPaint;
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 if ( handle )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10134 hdcPaint = GetDC( handle );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10135 else if ( pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10136 hdcPaint = pixmap->hdc;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10137 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10138 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10139
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10140 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
10141 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10142 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
10143 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
10144
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10145 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
10146 Polygon( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10147 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10148 Polyline( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10149
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10150 SelectObject( hdcPaint, oldBrush );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10151 SelectObject( hdcPaint, oldPen );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10152 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10153
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10154 if ( !pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10155 ReleaseDC( handle, hdcPaint );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10156 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10157 #endif
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10158 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10159 free(points);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10160 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10161
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
10162 /* 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
10163 * 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
10164 * 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
10165 * 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
10166 * 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
10167 * 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
10168 * 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
10169 * 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
10170 * 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
10171 */
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
10172 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
10173 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10174 #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
10175 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
10176
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10177 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10178 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
10179 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
10180 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
10181 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10182 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10183
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10184 /* 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
10185 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
10186 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
10187
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10188 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
10189 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10190 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
10191
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10192 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
10193 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10194 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10195 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10196 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
10197
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10198 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
10199 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10200 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10201 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10202 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10203 RECT Rect;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10204
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10205 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10206 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
10207 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
10208 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
10209 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10210 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10211
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10212 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
10213 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
10214 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
10215 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10216 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
10217 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10218 ReleaseDC(handle, hdcPaint);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10219 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10221
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10222 /* 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
10223 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10224 * 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
10225 * 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
10226 * 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
10227 * 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
10228 * 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
10229 * 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
10230 * 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
10231 * 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
10232 * 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
10233 * 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
10234 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10235 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
10236 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10237 #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
10238 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
10239 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
10240
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10241 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10242 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
10243 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
10244 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
10245 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10246 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10247
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10248 /* 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
10249 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
10250 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
10251
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10252 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
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_FILL)
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 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
10257
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10258 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
10259 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10260 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10261 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
10262 }
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
10263 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10264 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10265 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
10266 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
10267 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
10268 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
10269 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
10270 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
10271 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
10272
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10273 /* 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
10274 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
10275 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
10276 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
10277
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10278 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
10279 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10280 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10281 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10282 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10283 HBRUSH oldBrush;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10284 HPEN oldPen;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10285 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
10286 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
10287 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
10288 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
10289
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10290 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10291 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
10292 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
10293 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
10294 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10295 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10296
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10297 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
10298 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
10299 else
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, 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
10301 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
10302 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
10303 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
10304 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10305 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
10306 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
10307 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
10308
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10309 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10310 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
10311 #endif
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10312 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10313
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10314 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10315 /* 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
10316 * 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
10317 */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10318 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
10319 {
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10320 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
10321 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
10322 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
10323 {
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10324 if(mult)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10325 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10326 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10327 *x *= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10328 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10329 *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
10330 }
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10331 else
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10332 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10333 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10334 *x /= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10335 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10336 *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
10337 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10338 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10339 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10340 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10341
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10342 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10343 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10344 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10345 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10350 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
10351 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10352 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10353 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10354 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
10355 ColorInfo *cinfo = NULL;
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10356 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
10357 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10358
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10359 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10360 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10361 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10362 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10363 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10364 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10365
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10366 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10367 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
10368 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
10369 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
10370 else if(pixmap->handle)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10371 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10372
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10373 if(cinfo)
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 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10376 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10377 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10378
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10379 background = (COLORREF)(uintptr_t)TlsGetValue(_background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10380 if(hFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10381 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
10382 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
10383 if(background == DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10384 SetBkMode(hdc, TRANSPARENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10385 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10386 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10387 SetBkMode(hdc, OPAQUE);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10388 SetBkColor(hdc, background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10389 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10390 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10391 _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
10392 #endif
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10393 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
10394 if(oldFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10395 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10396 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10397 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10398 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10399 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10400 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10401
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
10402 /* 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
10403 * 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
10404 * 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
10405 * 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
10406 * 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
10407 * 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
10408 * 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
10409 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
10410 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
10411 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10412 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10413 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10414 HFONT hFont = NULL, oldFont;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10415 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
10416 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10417
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10418 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10419 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10420 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10421 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10422 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10423 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10424
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
10425 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
10426 {
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 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
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 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10430 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10431 ColorInfo *cinfo;
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 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10434 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10435 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10436 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10437
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10438 if(cinfo)
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 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10441 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10442 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10443 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10444 oldFont = SelectObject(hdc, hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10445
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10446 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
10447
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10448 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10449 *width = sz.cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10450
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10451 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10452 *height = sz.cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10453
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10454 #ifdef GDIPLUS
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10455 _convert_dpi(hdc, width, height, FALSE);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10456 #endif
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10457
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10458 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10459 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10460 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10461 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10462 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
10463 }
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
10464
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10465 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10468 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10470 }
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 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10474 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10475 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10476 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10477 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10478 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10479 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10480 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10481 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10482 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
10483 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10484 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10485 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10486
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10487 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10488 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10489
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10490 hdc = GetDC(handle);
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 pixmap->width = width; pixmap->height = height;
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->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10495 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10496 pixmap->hdc = CreateCompatibleDC(hdc);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10497 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10498
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10499 SelectObject(pixmap->hdc, pixmap->hbm);
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 ReleaseDC(handle, hdc);
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 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10504 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10505
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
10506 #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
10507 /* 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
10508 * 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
10509 * 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
10510 */
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 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
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 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
10514 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
10515 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
10516 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
10517 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
10518
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 /* 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
10520 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
10521 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
10522
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10523 /* 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
10524 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
10525 {
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 /* Couldn't read the file header */
967
c8490b0d8577 Minor formatting fix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 966
diff changeset
10527 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
10528 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
10529 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10530
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10531 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
10532 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10533 /* 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
10534 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
10535 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
10536 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10537
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 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
10539 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
10540 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10541 /* 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
10542 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
10543 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
10544 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10545
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 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
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 /* 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
10549 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
10550 }
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 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
10552 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
10553 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
10554 }
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
10555 #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
10556
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10557 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10558 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10559 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10560 * 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
10561 * 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
10562 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10563 * (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
10564 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10565 * 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
10566 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10567 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
10568 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10569 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10570 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10571 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
10572 #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
10573 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
10574 #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
10575
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 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
10577 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
10578
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10579 #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
10580 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
10581 #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
10582 file = _alloca(strlen(filename) + 5);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10583 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10584
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10585 /* 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
10586 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10587 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10588 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10589 strcat(file, ".bmp");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10590 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10591 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10592 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10593 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10594 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10595 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10596 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10597
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10598 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
10599 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
10600 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10601
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10602 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10603
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10604 if ( !pixmap->hbm )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10605 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10606 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10607 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10608 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10609
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
10610 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
10611
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10612 pixmap->hdc = CreateCompatibleDC( hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10613 GetObject( pixmap->hbm, sizeof(bm), &bm );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10614 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
10615 SelectObject( pixmap->hdc, pixmap->hbm );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10616 ReleaseDC( handle, hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10617 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10618
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10619 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10620 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10621
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10622 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10623 * 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
10624 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10625 * 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
10626 * 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
10627 * (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
10628 * 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
10629 * Returns:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10630 * 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
10631 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10632 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
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 pixmap;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10635 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
10636 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
10637 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
10638 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
10639
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10640 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
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 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
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
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10645 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
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 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
10648
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10649 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
10650 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
10651 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10652 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
10653 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
10654 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10655 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
10656 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
10657 #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
10658 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
10659 #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
10660 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
10661 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
10662 #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
10663 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10664 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10665 {
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
10666 _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
10667 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
10668 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
10669 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
10670 }
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
10671 _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
10672 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
10673 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10674
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10675 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
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 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
10678 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
10679 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
10680 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10681
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10682 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
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 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
10685
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10686 pixmap->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
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 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
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 ReleaseDC( handle, hdc );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10691 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10692
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10693 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
10694 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10695
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10696 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10697 * 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
10698 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10699 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
10700 {
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
10701 if ( pixmap && pixmap->depth < 32)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10702 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10703 pixmap->transcolor = _internal_color(color);
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 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10709 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10715 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10717 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10718 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10719 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10720
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10721 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10722 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10723
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10724 hdc = GetDC(handle);
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 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10727 pixmap->hdc = CreateCompatibleDC(hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10729 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
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 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
10732 pixmap->depth = bm.bmBitsPixel;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10733
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10734 SelectObject(pixmap->hdc, pixmap->hbm);
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 ReleaseDC(handle, hdc);
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10737 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10738
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10739 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10740 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10741
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10742 /*
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
10743 * 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
10744 * 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
10745 * 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
10746 * 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
10747 * 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
10748 * 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
10749 * 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
10750 * 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
10751 * 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
10752 */
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 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
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 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
10756 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
10757 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
10758
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10759 if(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
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 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
10762 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
10763 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
10764 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
10765 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
10766 }
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 }
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 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
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
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10772 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10773 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10774 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10775 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10777 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10779 if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10780 {
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
10781 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
10782 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
10783 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
10784 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
10785 free(pixmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10786 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10787 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10789 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10795 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10803 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
10804 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10805 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
10806 }
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10807
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 * 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
10810 * Parameters:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10811 * 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
10812 * 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
10813 * 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
10814 * 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
10815 * 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
10816 * 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
10817 * 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
10818 * 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
10819 * 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
10820 * 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
10821 * 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
10822 * 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
10823 * Returns:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10824 * 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
10825 */
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10826 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
10827 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10828 HDC hdcdest;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10829 HDC hdcsrc;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10830 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
10831 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
10832
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10833 /* Do some sanity checks */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10834 if ( dest )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10835 hdcdest = GetDC( dest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10836 else if ( destp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10837 hdcdest = destp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10838 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
10839 return DW_ERROR_GENERAL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10840
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10841 if ( src )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10842 hdcsrc = GetDC( src );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10843 else if ( srcp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10844 hdcsrc = srcp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10845 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
10846 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
10847
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10848 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
10849 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
10850
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10851 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
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 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
10854 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
10855 }
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10856
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10857 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10858 /* 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
10859 _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
10860 _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
10861 _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
10862 _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
10863 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10864
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10865 /* 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
10866 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
10867 {
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10868 /* Don't do anything */
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 /* 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
10871 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
10872 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10873 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
10874 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10875 else
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10876 {
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10877 /* 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
10878 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
10879 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
10880 else
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10881 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
10882 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10883 if ( !destp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10884 ReleaseDC( dest, hdcdest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10885 if ( !srcp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10886 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
10887
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10888 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10889 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10890
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
10891 /* 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
10892 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
10893 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10894 int *info = (int *)data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10895
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10896 if(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 Beep(info[0], info[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10899 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10900 }
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
10901 }
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10902
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10903 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10904 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10905 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10906 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10907 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10908 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10909 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10910 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10911 int *info = malloc(sizeof(int) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10912
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10913 if(info)
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 info[0] = freq;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10916 info[1] = dur;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10917
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10918 _beginthread(_beepthread, 100, (void *)info);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10919 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10920 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10921
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10922 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10923 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10924 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10925 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10926 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10927 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10928 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10929 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10930 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
10931 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10932
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10933 *handle = LoadLibrary(UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10934 return (NULL == *handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10935 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10936
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10937 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10938 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10939 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10940 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10941 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10942 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10943 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10944 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
10945 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10946 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
10947 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10949 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
10950 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10951
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10952 *func = (void*)GetProcAddress(handle, name);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10953 return (NULL == *func);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10954 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10955
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10956 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10957 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10958 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10959 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10960 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10961 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10962 return FreeLibrary(handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10963 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10964
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10965 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10966 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10967 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10968 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10970 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10974 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10975 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10976 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10977 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10978 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10979 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10980 CloseHandle((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10981 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10983 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10984 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10985 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10986 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10987 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10988 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10989 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10990 if(_dwtid == dw_thread_id())
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10991 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10992 int rc = WaitForSingleObject((HANDLE)mutex, 0);
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 while(rc == WAIT_TIMEOUT)
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 dw_main_sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10997 rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10998 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10999 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
11000 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11001 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11002 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11004 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11005 * 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
11006 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11007 * 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
11008 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11009 * 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
11010 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11011 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
11012 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11013 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
11014 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
11015 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
11016 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11017
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11018 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11019 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11020 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11021 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11022 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11023 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11025 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11027
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11029 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11031 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 {
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
11033 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11037 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11038 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11039 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11041 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042 {
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
11043 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
11044 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
11045 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11046 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11047
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11048 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11049 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11050 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11051 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11052 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11053 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11054 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 {
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
11056 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
11057 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
11058 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
11059 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11060
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11061 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11062 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11063 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11066 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11067 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11068 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11069 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11070
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
11071 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
11072 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
11073 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
11074 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
11075 return DW_ERROR_TIMEOUT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11076 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
11077 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
11078 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11079 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11080
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11081 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11082 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11085 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11086 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 {
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
11088 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
11089 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
11090 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
11091 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11092
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 /* 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
11094 * 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
11095 * 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
11096 * 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
11097 * 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
11098 * 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
11099 */
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 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
11101 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11102 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11103
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11104 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11105 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11106 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11107
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11108 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
11109 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11110
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 /* 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
11112 * 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
11113 * 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
11114 * 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
11115 */
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 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
11117 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11118 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
11119 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11120
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 /* 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
11122 * 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
11123 * 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
11124 * 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
11125 * 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
11126 */
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 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
11128 {
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
11129 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
11130 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
11131 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
11132 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11133
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 /* 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
11135 * 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
11136 * 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
11137 * 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
11138 * 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
11139 */
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 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
11141 {
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
11142 if(SetEvent(eve))
1170
4b94c9f5ddeb Missing return on Windows... surprised this compiled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
11143 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
11144 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
11145 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11146
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 /* 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
11148 * 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
11149 * 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
11150 * 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
11151 * 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
11152 * 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
11153 * 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
11154 */
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 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
11156 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11157 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11158
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
11159 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
11160 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
11161 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
11162 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
11163 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
11164 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
11165 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
11166 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
11167 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11168
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 /* 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
11170 * 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
11171 * 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
11172 * 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
11173 * 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
11174 */
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 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
11176 {
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
11177 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
11178 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
11179 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
11180 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11181
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 * 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
11184 * 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
11185 * 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
11186 * 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
11187 * 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
11188 * 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
11189 */
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 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
11191 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11192 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11193 HSHM handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11194
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11195 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11196 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11197 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11198
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11199 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
11200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11201 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11202 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11203
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11204 *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
11205
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11206 if(!*dest)
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 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11209 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11210 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11211
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11212 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
11213 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11214
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 * 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
11217 * 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
11218 * 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
11219 * 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
11220 * 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
11221 */
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 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
11223 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11224 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
11225
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11226 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11227 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11228
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11229 *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
11230
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11231 if(!*dest)
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 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11234 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11235 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11236
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11237 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
11238 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11239
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 * 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
11242 * 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
11243 * 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
11244 * 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
11245 */
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 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
11247 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11248 UnmapViewOfFile(ptr);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11249 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11250 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11251 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11252
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11253 /*
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11254 * Encapsulate thread creation on Win32.
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11255 */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11256 void _dwthreadstart(void *data)
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 (* threadfunc)(void *) = NULL;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11259 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
11260 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
11261 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
11262 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11263 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
11264 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
11265 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11266
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11267 _init_thread();
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 threadfunc = (void (*)(void *))tmp[0];
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11270 threadfunc(tmp[1]);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11271
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11272 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
11273 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
11274 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
11275 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
11276 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
11277 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11278 if((brush = TlsGetValue(_gpBrush)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11279 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
11280 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
11281 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
11282 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11283 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11284
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11285 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11286 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11287 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11288 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11289 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11290 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11291 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11292 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11293 {
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
11294 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11295 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
11296 #else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11297 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
11298
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11299 tmp[0] = func;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11300 tmp[1] = data;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11301
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11302 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
11303 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11304 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11305
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11306 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11307 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11308 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11309 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11310 {
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
11311 #if !defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11312 _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
11313 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11316 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11317 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11318 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11319 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11320 {
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
11321 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11322 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
11323 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11324 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
11325 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11328 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11329 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11330 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11331 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11332 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11333 void API dw_exit(int exitcode)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11334 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11335 OleUninitialize();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11336 #ifdef AEROGLASS
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11337 /* 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
11338 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
11339 #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
11340 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
11341 DestroyWindow(hwndTooltip);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11342 exit(exitcode);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11345 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11346 * 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
11347 * 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
11348 * 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
11349 * 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
11350 * 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
11351 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11352 * 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
11353 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11354 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
11355 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11356 HWND tmp = CreateWindow(SplitbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11357 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11358 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
11359 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11360 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
11361 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11362 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11363 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11364
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11365 if(tmp)
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 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
11368 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11369
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11370 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
11371 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
11372 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
11373
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11374 tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11375 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
11376 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
11377 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
11378 *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
11379 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
11380 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
11381 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11382 return tmp;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11383 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11384
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 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11387 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11388 * 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
11389 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11390 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
11391 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11392 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
11393 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
11394 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
11395
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11396 if(mypercent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11397 *mypercent = percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11398
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11399 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
11400
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
11401 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
11402 _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
11403 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11404
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 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11407 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11408 * 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
11409 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11410 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
11411 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11412 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
11413
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11414 if(percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11415 return *percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11416 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11417 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11418
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11419 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11420 * Creates a calendar window (widget) with given parameters.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11421 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11422 * type: Value can be DW_VERT or DW_HORZ.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11423 * topleft: Handle to the window to be top or left.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11424 * bottomright: Handle to the window to be bottom or right.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11425 * Classname: SysMonthCal32
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11426 * Returns:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11427 * A handle to a calendar window or NULL on failure.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11428 */
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11429 HWND API dw_calendar_new(unsigned long id)
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11430 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11431 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11432 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11433 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11434 MONTHCAL_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11435 NULL,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11436 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
11437 0,0,0,0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11438 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
11439 (HMENU)(uintptr_t)id,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11440 DWInstance,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11441 NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11442 if ( tmp )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11443 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11444 // 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
11445 MonthCal_GetMinReqRect(tmp, &rc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11446 // 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
11447 SetWindowPos(tmp, NULL, 0, 0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11448 rc.right, rc.bottom,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11449 SWP_NOZORDER | SWP_NOMOVE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11450 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
11451 MonthCal_SetDayState(tmp,3,mds);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11452 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11453 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11454 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11455 return NULL;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11456 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11457
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 * Sets the current date of a calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11460 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11461 * 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
11462 * year: The year to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11463 * month: The month to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11464 * day: The day to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11465 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11466 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
11467 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11468 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11469 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11470 date.wYear = year;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11471 date.wMonth = month;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11472 date.wDay = day;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11473 if ( MonthCal_SetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11474 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11475 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11476 else
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11479 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
11480 MonthCal_SetDayState(handle,3,mds);
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11481 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11482
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 * Gets the date from the calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11485 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11486 * 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
11487 * year: Pointer to the year to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11488 * month: Pointer to the month to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11489 * day: Pointer to the day to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11490 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11491 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
11492 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11493 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11494 if ( MonthCal_GetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11495 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11496 *year = date.wYear;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11497 *month = date.wMonth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11498 *day = date.wDay;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11499 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11500 else
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 *year = *month = *day = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11503 }
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11504 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11505
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
11506 /* 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
11507 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
11508 {
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 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
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
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11512 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11513 * 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
11514 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11515 * 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
11516 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11517 * 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
11518 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11519 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
11520 {
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
11521 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
11522 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
11523 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
11524 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
11525 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11526
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11527 /*
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
11528 * 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
11529 * 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
11530 * 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
11531 * 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
11532 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11533 * 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
11534 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11535 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
11536 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11537 Box *thisbox = (Box *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11538
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11539 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11540 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
11541 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11542
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 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11544 * 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
11545 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11546 * 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
11547 * 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
11548 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11549 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
11550 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11551 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11552
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11553 if (cinfo)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11554 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11555 cinfo->clickdefault = next;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11556 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11557 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11558
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11559 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11560 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11561 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11562 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11563 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11564 * 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
11565 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11566 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11567 char * API dw_clipboard_get_text(void)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11568 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11569 HANDLE handle;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11570 char *ret = NULL;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11571 TCHAR *tmp;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11572 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11573 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11574 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11575 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11576 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11577
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11578 if ( !OpenClipboard( NULL ) )
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11579 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11580
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11581 if ( ( handle = GetClipboardData(type) ) == NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11582 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11583 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11584 return ret;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11585 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11586
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11587 if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) )
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11588 {
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11589 ret = _strdup(WideToUTF8(tmp));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11590 GlobalUnlock(handle);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11591 }
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11592 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11593 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11594 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11595
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 * 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
11598 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11599 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11600 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11601 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
11602 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11603 HGLOBAL ptr1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11604 LPTSTR ptr2;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11605 TCHAR *buf;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11606 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11607 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11608 char *src = calloc(len + 1, 1);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11609
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11610 memcpy(src, str, len);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11611 buf = UTF8toWide(src);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11612 free(src);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
11613 len = (int)_tcslen(buf);
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11614 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11615 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11616
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11617 buf = str;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11618 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11619
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11620 if ( !OpenClipboard( NULL ) )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11621 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11622
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11623 ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
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 if ( !ptr1 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11626 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11627
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11628 ptr2 = GlobalLock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11629
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11630 memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11631 GlobalUnlock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11632 EmptyClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11633
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11634 SetClipboardData( type, ptr1 );
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11635
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11636 CloseClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11637 GlobalFree( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11638 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11639
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11640 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11641 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11642 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11643 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11644 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11645 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11646 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11647 if(!env)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11648 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11649
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11650 /* Get the Windows version. */
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 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11653 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11654
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11655 /* 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
11656
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11657 env->MinorBuild = 0;
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 if (dwVersion < 0x80000000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11660 {
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11661 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
11662 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
11663 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
11664 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
11665 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
11666 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
11667 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
11668 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
11669 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
11670 strcpy(env->osName, "Windows 8");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11671 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11672 strcpy(env->osName, "Windows NT");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11673
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11674 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
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 else
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 strcpy(env->osName, "Windows 95/98/ME");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11679 env->MajorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11680 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11681
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11682 strcpy(env->buildDate, __DATE__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11683 strcpy(env->buildTime, __TIME__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11684 env->DWMajorVersion = DW_MAJOR_VERSION;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11685 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
11686 #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
11687 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
11688 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11689 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
11690 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11691 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11692
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11693 /* 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
11694 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
11695 {
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11696 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
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 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
11699 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11700 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
11701 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
11702 else
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11703 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
11704 x++;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11705 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11706 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
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
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11709 #define BROWSEBUFSIZE 1000
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11710
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11711 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11712 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11713 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11714 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11715 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11716 * 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
11717 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11718 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11719 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
11721 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11723 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11725 OPENFILENAME of = {0};
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11726 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
11727 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
11728 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
11729 TCHAR *dpath = UTF8toWide(defpath);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11730 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11731
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11732 if ( flags == DW_DIRECTORY_OPEN )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11733 {
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
11734 /* 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
11735 #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
11736 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
11737 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
11738 LPITEMIDLIST pidl;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11739 LPMALLOC pMalloc;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11740
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11741 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11742 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11743 bi.hwndOwner = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11744 bi.pszDisplayName = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11745 bi.pidlRoot = 0;
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11746 bi.lpszTitle = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11747 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11748 bi.lpfn = NULL; /*BrowseCallbackProc*/
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11749
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11750 pidl = SHBrowseForFolder(&bi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11751 if (pidl)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11752 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11753 if (SHGetPathFromIDList(pidl,szDir))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11754 {
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11755 _tcsncpy(filenamebuf,szDir,BROWSEBUFSIZE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11756 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11757
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11758 /* 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
11759 pMalloc->lpVtbl->Free(pMalloc,pidl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11760 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
11761 return _strdup(WideToUTF8(filenamebuf));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11762 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11763 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11764 #else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11765 if ( XBrowseForFolder( NULL,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11766 (LPCTSTR)dpath,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11767 -1,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11768 (LPCTSTR)UTF8toWide(title),
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11769 (LPTSTR)filenamebuf,
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11770 BROWSEBUFSIZE,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11771 FALSE ) )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11772 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11773 return _strdup( WideToUTF8(fbuf) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11774 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11775 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11776 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11777 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11778 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11779 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
11780
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11781 if (ext)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11782 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11783 /*
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11784 * 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
11785 * 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
11786 */
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11787 int len;
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11788 TCHAR *ptr = filterbuf;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11789 TCHAR *start = filterbuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11790
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11791 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
11792 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
11793 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
11794 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
11795 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
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("*.*") );
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11798 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11799
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11800 memset( &of, 0, sizeof(OPENFILENAME) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11801
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11802 of.lStructSize = sizeof(OPENFILENAME);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11803 of.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11804 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
11805 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
11806 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
11807 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
11808 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
11809 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
11810 _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
11811 of.lpstrFile = filenamebuf;
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11812 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
11813 of.nFilterIndex = 1;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11814 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
11815 /*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
11816 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
11817
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11818 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
11819 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11820 of.Flags |= OFN_OVERWRITEPROMPT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11821 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
11822 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11823 else
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11824 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11825 of.Flags |= OFN_FILEMUSTEXIST;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11826 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
11827 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11828
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11829 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
11830 return _strdup(WideToUTF8(of.lpstrFile));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11831 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11832 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11833 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11834
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11835 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11836 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11837 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11838 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11839 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11840 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11841 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11842 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11843 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11844 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11845 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11846 char **newparams;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11847 int retcode, count = 0, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11848
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11849 while(params[count])
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 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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11854 newparams = (char **)malloc(sizeof(char *) * (count+1));
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 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11857 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11858 newparams[z] = malloc(strlen(params[z])+3);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11859 strcpy(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11860 strcat(newparams[z], params[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11861 strcat(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11862 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11863 newparams[count] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11864
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
11865 /* 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
11866 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
11867
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11868 for(z=0;z<count;z++)
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 free(newparams[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);
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 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11875 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11877 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11878 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11880 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11881 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11882 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11883 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11884 char *browseurl = url;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11885 int retcode;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11886
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11887 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
11888 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11889 int len, z;
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 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
11892 len = (int)strlen(browseurl);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11893
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11894 for(z=0;z<len;z++)
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 if(browseurl[z] == '|')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11897 browseurl[z] = ':';
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11901 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11902
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11903 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
11904 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
11905 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
11906 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11907 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11908
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11909 typedef struct _dwprint
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11910 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11911 PRINTDLG pd;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11912 DOCINFO di;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11913 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
11914 void *drawdata;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11915 unsigned long flags;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11916 } DWPrint;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11917
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11918 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11919 * 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
11920 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11921 * 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
11922 * 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
11923 * 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
11924 * 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
11925 * 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
11926 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11927 * 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
11928 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11929 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
11930 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11931 DWPrint *print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11932
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11933 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
11934 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11935
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11936 print->drawfunc = drawfunc;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11937 print->drawdata = drawdata;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11938 print->pd.lStructSize = sizeof(PRINTDLG);
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11939 print->pd.hwndOwner = HWND_DESKTOP;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11940 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
11941 print->pd.nCopies = 1;
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11942 print->pd.nFromPage = 1;
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11943 print->pd.nToPage = pages;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11944 print->pd.nMinPage = 1;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11945 print->pd.nMaxPage = pages;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11946
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11947 if(!PrintDlg(&(print->pd)))
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11948 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11949 free(print);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11950 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11951 }
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11952
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11953 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
11954 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
11955 return print;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11956 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11957
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 * 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
11960 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11961 * 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
11962 * 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
11963 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11964 * 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
11965 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11966 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
11967 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11968 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11969 HPIXMAP pixmap;
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11970 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
11971
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11972 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
11973 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11974
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11975 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
11976 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11977
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11978 width = GetDeviceCaps(p->pd.hDC, HORZRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11979 height = GetDeviceCaps(p->pd.hDC, VERTRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11980
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11981 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
11982 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
11983 pixmap->transcolor = DW_RGB_TRANSPARENT;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11984
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11985 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11986 /* 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
11987 _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
11988 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11989
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11990 pixmap->width = width;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11991 pixmap->height = height;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11992
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11993 SelectObject(pixmap->hdc, pixmap->hbm);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11994
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11995 /* Start the job */
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11996 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
11997
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11998 /* Cycle through each page */
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11999 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
12000 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12001 StartPage(p->pd.hDC);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12002 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
12003 EndPage(p->pd.hDC);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12004 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12005 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
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 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
12008 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
12009 }
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 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
12011 AbortDoc(p->pd.hDC);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12012 /* Free memory */
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12013 dw_pixmap_destroy(pixmap);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12014 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
12015 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12016 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12017
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 * 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
12020 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12021 * 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
12022 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12023 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
12024 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12025 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12026
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12027 if(p)
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12028 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
12029 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12030
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12031 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12032 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12033 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12034 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12035 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12036 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12037 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12038 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
12039
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12040 if(!_user_dir[0])
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 HANDLE hToken = 0;
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
12043
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12044 /* 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
12045 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
12046 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12047 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
12048 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
12049
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12050 GetUserProfileDirectory(hToken, Buf, &BufSize);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12051 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
12052 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
12053 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12054 /* 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
12055 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12056 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12057 strcpy(_user_dir, "C:\\");
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 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12060 return _user_dir;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12061 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12062
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12063 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12064 * 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
12065 * 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
12066 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
12067 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
12068 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12069 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
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
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12072 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12073 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12074 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12075 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12076 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12077 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12078 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12079 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12080 {
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
12081 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12083
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12084 /* 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
12085 * 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
12086 * 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
12087 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12088 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
12089 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12090 UserData *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12091
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12092 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12093 {
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
12094 if(_stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12095 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12096 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12097 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12098 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
12099 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12100
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12101 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
12102 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12103 UserData *new = _find_userdata(root, varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12104
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12105 if(new)
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 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12108 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12109 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12110 else
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 new = malloc(sizeof(UserData));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12113 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12114 {
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
12115 new->varname = _strdup(varname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12116 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12117
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12118 new->next = NULL;
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 if (!*root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12121 *root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12122 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12123 {
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
12124 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
12125
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12126 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12127 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12128 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12129 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12130 }
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
12131 prev->next = new;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12132 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12133 return TRUE;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12136 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
12137 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12138
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12139 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
12140 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12141 UserData *prev = NULL, *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12142
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12143 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12144 {
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
12145 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
12146 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12147 if(!prev)
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 *root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12150 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12151 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12152 if(!all)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12153 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12154 tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12155 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12156 else
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 /* If all is true we should
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12159 * never get here.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12160 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12161 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12162 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12163 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12164 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12166 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12167 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12170 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12171 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12172 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12173 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
12174 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12175
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 * 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
12178 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12179 * 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
12180 * 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
12181 * 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
12182 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12183 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
12184 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12185 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12186
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12187 if(!cinfo)
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(!dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12190 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12191
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12192 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12193 cinfo->fore = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12194 SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12195 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12196
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12197 if(cinfo)
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(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12200 _new_userdata(&(cinfo->root), dataname, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12201 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12202 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12203 if(dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12204 _remove_userdata(&(cinfo->root), dataname, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12205 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12206 _remove_userdata(&(cinfo->root), NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12207 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12208 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12209 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12210
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 * 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
12213 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12214 * 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
12215 * 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
12216 * 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
12217 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12218 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
12219 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12220 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12221
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12222 if(cinfo && cinfo->root && dataname)
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 UserData *ud = _find_userdata(&(cinfo->root), dataname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12225 if(ud)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12226 return ud->data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12227 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12228 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
12229 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12230
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12231 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12232 * 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
12233 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12234 * 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
12235 * 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
12236 * 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
12237 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12238 * 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
12239 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12240 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
12241 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12242 if(sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12243 {
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
12244 /* 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
12245 * 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
12246 */
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 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
12248
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12249 if(timerid)
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 _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
12252 return timerid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12253 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12254 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12255 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
12256 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12257
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 * 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
12260 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12261 * 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
12262 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12263 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
12264 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12265 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12266
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12267 /* 0 is an invalid timer ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12268 if(!id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12269 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12270
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12271 KillTimer(NULL, id);
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 while(tmp)
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 if(tmp->id == id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12276 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12277 if(prev)
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 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12280 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12281 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12282 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12283 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12286 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12287 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12288 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12289 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12290 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12293 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12294 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12295 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12296 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12297
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12298 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12299 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12300 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12301 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12302 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12303 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12304 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12305 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12306 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12307 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12308 ULONG message = 0, id = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12309
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12310 if (window && signame && sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12311 {
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
12312 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
12313 window = _normalize_handle(window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12314
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12315 if ((message = _findsigmessage(signame)) != 0)
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 /* Handle special case of the menu item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12318 if (message == WM_COMMAND && window < (HWND)65536)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12319 {
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
12320 char buffer[16];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12321 HWND owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12322
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12323 _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
12324 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
12325
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
12326 /* 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
12327 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
12328
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12329 if (owner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12330 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12331 id = (ULONG)(uintptr_t)window;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12332 window = owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12333 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12334 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12335 _new_signal(message, window, id, sigfunc, data);
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 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12338 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12340 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12341 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12343 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12344 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12345 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12346 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12347 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12348 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12349
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12350 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12351 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12352
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12353 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12354 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12355 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
12356 {
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
12357 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12358 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12359 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12360 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12361 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12362 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12363 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12366 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12367 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12368 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12369 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12370 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12373 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12374 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12375 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12376 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12377
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12378 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12379 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12380 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12381 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12382 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12383 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12384 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12385 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12386
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12387 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12388 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12389 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
12390 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12391 if(prev)
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 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12394 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12395 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12396 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12397 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12400 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12401 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12402 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12403 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12404 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12407 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12408 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12409 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12410 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12411
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12412 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12413 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12414 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12415 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12416 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12417 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12418 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12419 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12420 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12421
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12422 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12423 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12424 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
12425 {
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
12426 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12427 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12428 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12429 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12430 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12431 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12432 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12435 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12436 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12437 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12438 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12439 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12442 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12443 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12444 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12445 }
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12446
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12447 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12448 * 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
12449 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12450 * 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
12451 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12452 * 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
12453 * 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
12454 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12455 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
12456 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12457 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12458 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
12459 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12460 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12461 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12462 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12463
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 * 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
12466 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12467 * 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
12468 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12469 * 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
12470 * 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
12471 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12472 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
12473 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12474 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12475 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
12476 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12477 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12478 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12479 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12480